Skip to content

Commit

Permalink
修复调整导航栏间距无效的问题#76
Browse files Browse the repository at this point in the history
  • Loading branch information
QuintGao committed May 14, 2021
1 parent 4afa11b commit e5e3dbc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 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.5.4'
s.version = '1.5.5'
s.license = 'MIT'
s.summary = '自定义导航栏--导航栏联动'
s.homepage = 'https://github.com/QuintGao/GKNavigationBar'
Expand Down
20 changes: 17 additions & 3 deletions GKNavigationBar/NavigationBar/UIViewController+GKNavigationBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
}

Expand Down Expand Up @@ -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;
// 根控制器不作处理
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ configure.shiledGuestureVCs = @[NSClassFromString(@"TZPhotoPickerController"), @
<summary><font size=4>最近更新</font></summary>

```
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,可全局配置
Expand Down

0 comments on commit e5e3dbc

Please sign in to comment.