我正在尝试在导航堆栈上推视图控制器时更改导航栏的颜色,在navigationController(_:willShow:animated :)期间使用barTintColor。
这是代码:
func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
if viewController is ViewerViewController {
navigationBar.barTintColor = UIColor(custom: .white)
navigationBar.tintColor = UIColor(custom: .black)
} else if viewController is FeedViewController {
navigationBar.barTintColor = UIColor(custom: .blue)
navigationBar.tintColor = UIColor(custom: .white)
}
}
当我按下视图控制器和使用向后滑动手势时,一切工作都很好(两种方式的颜色过渡都很平滑)。
但是,当我按下“后退”按钮时,颜色一开始并没有改变,完成了导航转换,然后没有动画就改变了颜色。
是否有人已经遇到/解决了这个问题?任何线索将不胜感激。
我最终使用了KMNavigationBarTransition库,该库工作得很好,不需要一行代码。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句