1.今天更新了xcode13,运行项目发现iOS15以上的手机导航栏和状态栏之前设置的颜色等属性都不起作用了,都变成了黑色,滚动的时候才能变成正常的颜色,经确认得用UINavigationBarAppearance和UITabBarAppearance这两个属性对导航栏和状态栏设置才能生效。以下是示例代码(仅是背景颜色),具体属性根据自己实际情况进行设置
if (@available(iOS 15.0, *)) {
UINavigationBarAppearance * bar = [UINavigationBarAppearance new];
bar.backgroundColor = [UIColor blueColor];
bar.backgroundEffect = nil;
self.navigationController.navigationBar.scrollEdgeAppearance = bar;
self.navigationController.navigationBar.standardAppearance = bar;
UITabBarAppearance * bar2 = [UITabBarAppearance new];
bar2.backgroundColor = [UIColor whiteColor];
bar2.backgroundEffect = nil;
self.tabBarController.tabBar.scrollEdgeAppearance = bar2;
self.tabBarController.tabBar.standardAppearance = bar2;
} else {
// Fallback on earlier versions
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)