前言
iOS 15在2021 WWDC會后發(fā)布挽鞠,就勇猛的把水果全家桶都升級了最新系統(tǒng)。兩個iOS 15 beta版本過后姑原,系統(tǒng)穩(wěn)定性整體還不錯岭妖。也隨之發(fā)現(xiàn)了幾個iOS適配上的bug徽曲,在此整理記錄下來零截。后續(xù)有發(fā)現(xiàn)再繼續(xù)補充。
Xcode Version 13.0 beta
iOS 15 Developer Beta2
1. UINavigationBar
- 在iOS 15中秃臣,UINavigationBar默認(rèn)為透明涧衙。在滑動時會有模糊效果。如果想要一直就是模糊效果奥此,可以通過改變scrollEdgeAppearance屬性來實現(xiàn)弧哎。
解決辦法:
UINavigationBarAppearance *barApp = [[UINavigationBarAppearance alloc] init];
barApp.backgroundEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleRegular];
self.navigationBar.scrollEdgeAppearance = barApp;
- NavigationBar顏色設(shè)置無效
self.navigationController.navigationBar.barTintColor = [[UIColor blueColor] colorWithAlphaComponent:0.5];
往常我們用以上代碼來設(shè)置導(dǎo)航欄和狀態(tài)欄背景色,此代碼在iOS 15的無效稚虎。
apple developer forums
As of iOS 15, UINavigationBar, UIToolbar, and UITabBar will use their scrollEdgeAppearance when your view controller's associated scroll view is at the appropriate edge (or always if you don't have a UIScrollView in your hierarchy, more on that below).
You must adopt the UIBarAppearance APIs (available since iOS 13, specializations for each bar type) to customize this behavior. UIToolbar and UITabBar add scrollEdgeAppearance properties for this purpose in iOS 15.
從 iOS 15 開始撤嫩,UINavigationBar、UIToolbar 和 UITabBar 將在你的VC關(guān)聯(lián)滾動視圖位于適當(dāng)?shù)倪吘墪r使用 scrollEdgeAppearance(或者如果您的試圖層級結(jié)構(gòu)中沒有 UIScrollView蠢终,更多內(nèi)容見下文)序攘。
您必須使用 UIBarAppearance API 來自定義茴她。UIToolbar 和 UITabBar 為此在 iOS 15 中添加了 scrollEdgeAppearance 屬性。
/// Describes the appearance attributes for the tabBar to use when an observable scroll view is scrolled to the bottom. If not set, standardAppearance will be used instead.
@property (nonatomic, readwrite, copy, nullable) UITabBarAppearance *scrollEdgeAppearance UI_APPEARANCE_SELECTOR API_AVAILABLE(ios(15.0));
/// Describes the appearance attributes for the toolbar to use at standard height when an observable scroll view is scrolled to the bottom. If not set, standardAppearance will be used instead.
@property (nonatomic, readwrite, copy, nullable) UIToolbarAppearance *scrollEdgeAppearance UI_APPEARANCE_SELECTOR API_AVAILABLE(ios(15.0));
解決辦法:
if (@available(iOS 15.0, *)) {
UINavigationBarAppearance *barApp = [UINavigationBarAppearance new];
barApp.backgroundColor = [[UIColor blueColor] colorWithAlphaComponent:0.5];
self.navigationController.navigationBar.scrollEdgeAppearance = barApp;
self.navigationController.navigationBar.standardAppearance = barApp;
}
2. iOS 15 UITableView sectionHeader下移22像素
iOS 15中 UITableView 新增了一個屬性:sectionHeaderTopPadding程奠。此屬性會給每一個 section header 增加一個默認(rèn)高度丈牢,當(dāng)我們使用 UITableViewStylePlain 初始化UITableView 的時候,系統(tǒng)默認(rèn)給 section header 增高了22像素梦染。
/// Padding above each section header. The default value is
UITableViewAutomaticDimension
.
@property (nonatomic) CGFloat sectionHeaderTopPadding API_AVAILABLE(ios(15.0), tvos(15.0), watchos(8.0));
解決辦法:
if (@available(iOS 15.0, *)) {
tableView.sectionHeaderTopPadding = 0;
}