iOS 15 適配
1.滑動導航欄變白
2.滑動tabBar背景色變化
3.tabItem文字顏色不會改變,默認系統(tǒng)藍色
4.UITableView 頂部多出空白
對更新到iOS15后慨亲,出現(xiàn)的問題婚瓜,可以分別做以下設置進行適配:
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
}