Skip to content

Commit

Permalink
修复bug #90,release 1.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
QuintGao committed Nov 8, 2021
1 parent 721577f commit cb68779
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 35 deletions.
2 changes: 1 addition & 1 deletion GKNavigationBar.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'GKNavigationBar'
s.version = '1.6.0'
s.version = '1.6.1'
s.license = 'MIT'
s.summary = '自定义导航栏--导航栏联动'
s.homepage = 'https://github.com/QuintGao/GKNavigationBar'
Expand Down
5 changes: 0 additions & 5 deletions GKNavigationBar/GestureHandle/GKBaseAnimatedTransition.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ NS_ASSUME_NONNULL_BEGIN
/// 动画完成
- (void)completeTransition;


/// 获取某个view的截图
/// @param view 截图
- (UIImage *)getCaptureWithView:(UIView *)view;

@end

@interface UIViewController (GKCapture)
Expand Down
8 changes: 0 additions & 8 deletions GKNavigationBar/GestureHandle/GKBaseAnimatedTransition.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ - (void)completeTransition {
[self.transitionContext completeTransition:!self.transitionContext.transitionWasCancelled];
}

- (UIImage *)getCaptureWithView:(UIView *)view {
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0);
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:NO];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}

@end

@implementation UIViewController (GKCapture)
Expand Down
7 changes: 7 additions & 0 deletions GKNavigationBar/GestureHandle/GKGestureHandleConfigure.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ NS_ASSUME_NONNULL_BEGIN
// 如果设置为YES,可在单个UIScrollView中通过设置gk_openGestureHandle关闭
@property (nonatomic, assign) BOOL gk_openScrollViewGestureHandle;

// 设置push时是否隐藏tabbar,默认NO
@property (nonatomic, assign) BOOL gk_hidesBottomBarWhenPushed;

/// 设置默认配置
- (void)setupDefaultConfigure;

Expand All @@ -56,6 +59,10 @@ NS_ASSUME_NONNULL_BEGIN
// 内部方法
- (BOOL)isVelocityInSensitivity:(CGFloat)velocity;

/// 获取某个view的截图
/// @param view view
- (UIImage *)getCaptureWithView:(UIView *)view;

@end

NS_ASSUME_NONNULL_END
8 changes: 8 additions & 0 deletions GKNavigationBar/GestureHandle/GKGestureHandleConfigure.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,12 @@ - (BOOL)isVelocityInSensitivity:(CGFloat)velocity {
return (fabs(velocity) - (1000.0f * (1 - self.gk_snapMovementSensitivity))) > 0;
}

- (UIImage *)getCaptureWithView:(UIView *)view {
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0);
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:NO];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}

@end
2 changes: 1 addition & 1 deletion GKNavigationBar/GestureHandle/GKPushAnimatedTransition.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ - (void)animateTransition {
__block UIView *fromView = nil;
if (self.isHideTabBar) {
// 获取fromViewController的截图
UIImage *captureImage = [self getCaptureWithView:self.fromViewController.view.window];
UIImage *captureImage = [GKGestureConfigure getCaptureWithView:self.fromViewController.view.window];
UIImageView *captureView = [[UIImageView alloc] initWithImage:captureImage];
captureView.frame = CGRectMake(0, 0, screenW, screenH);
[self.containerView addSubview:captureView];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,16 @@ + (void)load {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSArray <NSString *> *oriSels = @[@"viewDidLoad",
@"pushViewController:animated:",
@"navigationBar:shouldPopItem:",
@"dealloc"];
[oriSels enumerateObjectsUsingBlock:^(NSString * _Nonnull oriSel, NSUInteger idx, BOOL * _Nonnull stop) {
gk_gestureHandle_swizzled_instanceMethod(@"gkNav", self, oriSel, self);
gk_gestureHandle_swizzled_instanceMethod(@"gkGesture", self, oriSel, self);
}];
});
}

- (void)gkNav_viewDidLoad {
- (void)gkGesture_viewDidLoad {
if (self.gk_openGestureHandle) {
// 处理特殊控制器
if ([self isKindOfClass:[UIImagePickerController class]]) return;
Expand All @@ -88,11 +89,26 @@ - (void)gkNav_viewDidLoad {
// 注册控制器属性改变通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(propertyChangeNotification:) name:GKViewControllerPropertyChangedNotification object:nil];
}
[self gkNav_viewDidLoad];
[self gkGesture_viewDidLoad];
}

- (void)gkGesture_pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
if (self.childViewControllers.count > 0) {
UIViewController *rootVC = self.childViewControllers.firstObject;
// 获取tabbar截图
if (viewController.gk_systemGestureHandleDisabled && !rootVC.gk_captureImage) {
rootVC.gk_captureImage = [GKGestureConfigure getCaptureWithView:rootVC.view.window];
}
// 设置push时是否隐藏tabbar
if (GKGestureConfigure.gk_hidesBottomBarWhenPushed && rootVC != viewController) {
viewController.hidesBottomBarWhenPushed = YES;
}
}
[self gkGesture_pushViewController:viewController animated:animated];
}

// source:https://github.com/onegray/UIViewController-BackButtonHandler
- (BOOL)gkNav_navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item {
- (BOOL)gkGesture_navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item {
if ([self.viewControllers count] < [navigationBar.items count]) {
return YES;
}
Expand All @@ -119,11 +135,11 @@ - (BOOL)gkNav_navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINa
return NO;
}

- (void)gkNav_dealloc {
- (void)gkGesture_dealloc {
if (self.gk_openGestureHandle) {
[[NSNotificationCenter defaultCenter] removeObserver:self name:GKViewControllerPropertyChangedNotification object:nil];
}
[self gkNav_dealloc];
[self gkGesture_dealloc];
}

- (UIViewController *)childViewControllerForStatusBarHidden {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@
796CF7E4236D781400983E9B /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1240;
LastUpgradeCheck = 1300;
ORGANIZATIONNAME = QuintGao;
TargetAttributes = {
79672E92236EC8EB0054300B = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1240"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ - (void)pushTransition {
__block UIView *fromView = nil;
if (self.isHideTabBar) {
// 获取fromVC的截图
UIImage *captureImage = [self getCaptureWithView:self.fromViewController.view.window];
UIImage *captureImage = [GKGestureConfigure getCaptureWithView:self.fromViewController.view.window];
UIImageView *captureView = [[UIImageView alloc] initWithImage:captureImage];
captureView.frame = self.containerView.frame;
[self.containerView addSubview:captureView];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ - (void)dealloc {

- (void)pageAction {
GKWYNewsDetailViewController *detailVC = [GKWYNewsDetailViewController new];
detailVC.gk_systemGestureHandleDisabled = YES;
detailVC.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:detailVC animated:YES];
}
Expand Down
Loading

0 comments on commit cb68779

Please sign in to comment.