diff --git a/GKNavigationBar.podspec b/GKNavigationBar.podspec index 7177e82..a60f227 100644 --- a/GKNavigationBar.podspec +++ b/GKNavigationBar.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'GKNavigationBar' - s.version = '1.5.4' + s.version = '1.5.5' s.license = 'MIT' s.summary = '自定义导航栏--导航栏联动' s.homepage = 'https://github.com/QuintGao/GKNavigationBar' diff --git a/GKNavigationBar/NavigationBar/UIViewController+GKNavigationBar.m b/GKNavigationBar/NavigationBar/UIViewController+GKNavigationBar.m index 81ac7f9..92ef5d6 100644 --- a/GKNavigationBar/NavigationBar/UIViewController+GKNavigationBar.m +++ b/GKNavigationBar/NavigationBar/UIViewController+GKNavigationBar.m @@ -46,7 +46,7 @@ + (void)load { - (void)gk_viewDidLoad { // bug fix #76,修改添加了子控制器后调整导航栏间距无效的bug // 当创建了gk_navigationBar或者父控制器是导航控制器的时候才去调整导航栏间距 - if (self.gk_NavBarInit || [self.parentViewController isKindOfClass:[UINavigationController class]]) { + if ([self navItemSpaceChangeIfNeeded]) { // 设置默认导航栏间距 self.gk_navItemLeftSpace = GKNavigationBarItemSpace; self.gk_navItemRightSpace = GKNavigationBarItemSpace; @@ -75,17 +75,27 @@ - (void)gk_viewWillAppear:(BOOL)animated { } } - // 允许调整导航栏间距 - if (!self.gk_disableFixNavItemSpace) { + // bug fix #76,修改添加了子控制器后调整导航栏间距无效的bug + // 当创建了gk_navigationBar或者父控制器是导航控制器的时候才去调整导航栏间距 + if ([self navItemSpaceChangeIfNeeded] && !self.gk_disableFixNavItemSpace) { // 每次控制器出现的时候重置导航栏间距 if (self.gk_navItemLeftSpace == GKNavigationBarItemSpace) { self.gk_navItemLeftSpace = GKConfigure.navItemLeftSpace; + }else { + [GKConfigure updateConfigure:^(GKNavigationBarConfigure * _Nonnull configure) { + configure.gk_navItemLeftSpace = self.gk_navItemLeftSpace; + }]; } if (self.gk_navItemRightSpace == GKNavigationBarItemSpace) { self.gk_navItemRightSpace = GKConfigure.navItemRightSpace; + }else { + [GKConfigure updateConfigure:^(GKNavigationBarConfigure * _Nonnull configure) { + configure.gk_navItemRightSpace = self.gk_navItemRightSpace; + }]; } } + [self gk_viewWillAppear:animated]; } @@ -605,6 +615,10 @@ - (BOOL)checkFixNavItemSpace { return exist; } +- (BOOL)navItemSpaceChangeIfNeeded { + return self.gk_NavBarInit || [self.parentViewController isKindOfClass:[UINavigationController class]]; +} + - (void)setBackItemImage:(UIImage *)image { if (!self.gk_NavBarInit) return; // 根控制器不作处理 diff --git a/README.md b/README.md index e6e97f3..22e9a0c 100644 --- a/README.md +++ b/README.md @@ -206,7 +206,8 @@ configure.shiledGuestureVCs = @[NSClassFromString(@"TZPhotoPickerController"), @ 最近更新 ``` -1.5.4 - 2021.05.12 修复bug #76,修复可能提前触发viewDidLoad方法的问题 +1.5.5 - 2021.05.14 修复导航栏间距失效的问题#76 +1.5.4 - 2021.05.12 修复可能提前触发viewDidLoad方法的问题 1.5.3 - 2021.05.07 修复直接设置背景色无效的问题#71,#74,增加对非全屏的支持 1.5.2 - 2021.04.06 增加协议方法,解决返回手势与WKWebView中的手势冲突问题 1.5.1 - 2021.03.09 返回手势优化,新增backStyle对应的image,可全局配置