写的有点晚了哈!
升级iOS15之后,有没有发现你的App导航栏上的状态栏颜色变了呢?
if (@available(iOS 15.0, *)) {
UINavigationBarAppearance *appearance = [[UINavigationBarAppearance alloc] init];
appearance.backgroundEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleRegular];
self.navigationBar.scrollEdgeAppearance = appearance;
}
Tabbar的背景颜色值设置
if (@available(iOS 13.0, *)) {
UITabBarAppearance * appearance = [[UITabBarAppearance alloc] init];
// 背景色
appearance.backgroundColor = [UIColor whiteColor];
self.tabBar.standardAppearance = appearance;
if (@available(iOS 15.0, *)) {
self.tabBar.scrollEdgeAppearance = appearance;
}
}
if (@available(iOS 15.0, *)) {
tableView.sectionHeaderTopPadding = 0;
}
//或者全局设置
if (@available(iOS 15.0, *)) {
[UITableView appearance].sectionHeaderTopPadding = 0;
}
除此之外再增加一点,就是当iPad横屏时,如果UI底部使用了UITabbar的话,需要注意TabBar的位置。
未适配之前:
![请添加图片描述](https://img-blog.csdnimg.cn/de8f76e28c5e470c9c98b489738e8380.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBATW9ycmlzXw==,size_20,color_FFFFFF,t_70,g_se,x_16)
适配之后:
![请添加图片描述](https://img-blog.csdnimg.cn/691bb09642eb4ddd976db4bc63c9fc8c.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBATW9ycmlzXw==,size_20,color_FFFFFF,t_70,g_se,x_16)
// Tabbar frame
CGRect frame = CGRectMake(CGRectGetMinX(self.view.bounds), CGRectGetMaxY(self.view.bounds), self.view.bounds.size.width, 56.0);
if (@available(iOS 15.0, *)) {
frame.size.height += 20;
}