LTNavigationBar
LTNavigationBar copied to clipboard
ios10返回navigationBar颜色不会立马消失

+1
我试了一下,在上一个页面的ViewWillAppear里面,再用lt_setBackgroundColor,可以解决这种变化突兀的情况。感觉这就需要在相关的页面都设置这个,还是略麻烦。
我在ViewWillAppear设置了,还是有这种情况呢?
我也有这样的情况,上一层 viewWillAppear 并不能解决问题, @xd54622 请教下你是怎么设置的?
@sseen @github410117 我就是在上一层的viewWillAppear上加一个设置背景颜色的,感觉效果还好啊。 这是第一个页面设置的:
-
(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; // 这里是为了避免导航栏出现突兀的情况 [self.navigationController.navigationBar lt_setBackgroundColor:navBgColor]; }
-
(void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [self.navigationController.navigationBar lt_reset]; }
然后在第二个页面是这样设置的:
-
(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; self.tableView.delegate = self; [self scrollViewDidScroll:self.tableView]; [self.navigationController.navigationBar setShadowImage:[UIImage new]]; }
-
(void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; self.tableView.delegate = nil; [self.navigationController.navigationBar lt_reset]; }
@xd54622 谢了你的回复。不过还是没有任何作用,我只能不使用[self.navigationController.navigationBar lt_reset] 而用 [self.navigationController.navigationBar lt_setBackgroundColor:navBgColor] 来给子页面的导航栏设置颜色,依然不能用 uinavigationbar 的 appearance 来全局设置颜色,即便这样,效果也只是勉强能接受
同样遇到这个问题,通过这样一下方式解决(不是最佳实践,效果还能接受):
将 push 进来的页面的 backIndicator 用 leftBarButtonItem 代替。然后在点击方法中 pop 页面,就就会出现上面的现象
缺陷:
- 用 leftBarButtonItem 代替之后系统自带的滑动返回失效(可以解决)
- 视图(返回按钮位置)上可能有些偏差
希望能帮到你们~