从 iOS 15 开始,UINavigationBar、UIToolbar 和 UITabBar 在控制器中关联滚动视图顶部或底部时使用UINavigationBar.scrollEdgeAppearance配置相关属性-背景、字体等
Tablear 代码
if (@available(iOS 15.0, *)) {
UITabBarAppearance * appearance = [[UITabBarAppearance alloc] init];
[appearance configureWithOpaqueBackground];
appearance.backgroundColor = UIColor.whiteColor;
[UITabBar appearance].scrollEdgeAppearance = appearance;
[UITabBar appearance].standardAppearance = appearance;
}
[UITabBar appearance].backgroundColor = UIColor.whiteColor;
NavigationBar 代码
if ( @available(iOS 15.0, *) ) {
UINavigationBarAppearance * appearance1 = [[UINavigationBarAppearance alloc] init];
[appearance1 configureWithOpaqueBackground];
appearance1.backgroundColor = KnavigationbarColor;
NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
[attributes setValue:UIColor.whiteColor forKey:NSForegroundColorAttributeName];
appearance1.titleTextAttributes = attributes;
[UINavigationBar appearance].standardAppearance = appearance1;
[UINavigationBar appearance].scrollEdgeAppearance = appearance1;
[[UINavigationBar appearance] setScrollEdgeAppearance:appearance1];
[[UINavigationBar appearance]setStandardAppearance:appearance1];
}
iOS15中tableviewController 中新增
TableView 增加sectionHeaderTopPadding属性,默认情况sectionHeaderTopPadding会有22个像素的高度,及默认情况,TableView section header增加22像素的高度
if #available(iOS 15.0, *) {
self.tableView.sectionHeaderTopPadding = 0
}
网友评论