前两天更新了iOS15,发现navigationbar和tabbar上的颜色没了。设置过后也会上下各少了一截,上面是状态栏没颜色,下面是tabbar的安全区域没颜色。
经查阅和百度了一些文章,解决了这个问题,留个记录,我也能单独解决问题了😂😂😂
这个是 navigationbar中需要的-----改成ios13也管用
if(@available(iOS15.0, *)) {
[[UINavigationBar appearance]setBackgroundColor:ZZRGBHex(0x368AFF)];
UINavigationBarAppearance *appearance = [UINavigationBarAppearance new];
appearance.backgroundColor=ZZRGBHex(0x368AFF);
appearance.titleTextAttributes = @{NSForegroundColorAttributeName :[UIColor whiteColor]};
[UINavigationBar appearance].standardAppearance = appearance;
[UINavigationBar appearance].compactAppearance = appearance;
[UINavigationBar appearance].scrollEdgeAppearance = appearance;
}
tabbar中的更改
if(@available(iOS13.0, *)) {
UITabBarAppearance *appearance = [[UITabBarAppearance alloc] init];
appearance.backgroundColor=ZZRGBHex(0xffffff);
[UITabBar appearance].standardAppearance = appearance;
if(@available(iOS15.0, *)) {
[UITabBar appearance].scrollEdgeAppearance = appearance;
}
}
网友评论