问题
最近接手一个老项目,发现每次push一个新VC,导航栏状态栏都默认为黑色,并且在滚动的过程中渐变成白色,到处搜索都没定位到哪里配置了backgroundColor = blackColor
解决方案
其实是iOS13后苹果更新UINavigationBar属性参数配置问题引起,配置以下方法解决:
代码语言:javascript复制if (@available(iOS 13.0, *)) {
UINavigationBarAppearance *appearance = [UINavigationBarAppearance new];
[appearance configureWithOpaqueBackground];//重置导航栏背景颜色和阴影
appearance.backgroundColor = [UIColor whiteColor];
// appearance.shadowImage = [UIImage new];
// appearance.shadowColor = nil;
self.navigationController.navigationBar.standardAppearance = appearance;
self.navigationController.navigationBar.scrollEdgeAppearance = appearance;
}
参考:https://www.jianshu.com/p/63feddc18561