iOS 15 适配
1.滑动导航栏变白
2.滑动tabBar背景色变化
3.tabItem文字颜色不会改变,默认系统蓝色
4.UITableView 顶部多出空白
对更新到iOS15后,出现的问题,可以分别做以下设置进行适配:
1.对UINavigationBar做如下设置
if #available(iOS 15.0, *) {
let appearnce = UINavigationBarAppearance()
appearnce.configureWithOpaqueBackground()
appearnce.backgroundColor = HEX_ThemeBlack
appearnce.titleTextAttributes = [<#NSAttributedString#>,<#NSAttributedString#>]
navigationBar.standardAppearance = appearnce
navigationBar.scrollEdgeAppearance = appearnce
}
2.对UITabBar做如下设置
if #available(iOS 15.0, *) {
let appearnce = UITabBarAppearance()
appearnce.configureWithOpaqueBackground()
appearnce.backgroundColor = HEX_ThemeBlack
tabBarController.tabBar.standardAppearance = appearnce
tabBarController.tabBar.scrollEdgeAppearance = appearnce
}
3.对UITabBarItem做如下设置
if #available(iOS 15.0, *) {
let appearnce = UITabBarAppearance()
let itemAppearance = UITabBarItemAppearance()
itemAppearance.normal.titleTextAttributes = <#Dictionary<NSAttributeString.Key,Any>#>
itemAppearance.selected.titleTextAttributes = <#Dictionary<NSAttributeString.Key,Any>#>
appearnce.stackedLayoutAppearance = itemAppearance
appearnce.configureWithOpaqueBackground()
appearnce.backgroundColor = HEX_ThemeBlack
tabBarController.tabBar.standardAppearance = appearnce
tabBarController.tabBar.scrollEdgeAppearance = appearnce
}
4.对UITableView的设置
可以在基类的初始化方法中添加,也可以使用methodSwizzle去替换方法中添加
if #available(iOS 15.0, *) {
self.sectionHeaderTopPadding = 0
}