1彩郊,UINavigationBar、UIToolbar 和 UITabBar 相關屬性背景設置:
從 iOS 15 開始,UINavigationBar 使用UINavigationBar.scrollEdgeAppearance配置相關屬性-背景鲫凶、字體等替废。
if #available(iOS 15.0, *) {
let navBarAppearance = UINavigationBarAppearance()
// 背景色
navBarAppearance.backgroundColor = UIColor.clear
// 去掉半透明效果
navBarAppearance.backgroundEffect = nil
// 去除導航欄陰影(如果不設置clear,導航欄底下會有一條陰影線)
navBarAppearance.shadowColor = UIColor.clear
// 字體顏色
navBarAppearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
self.navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
}
2绎晃,TableView 的適配
從 iOS 15 開始蜜唾,TableView 增加sectionHeaderTopPadding屬性杂曲,默認情況sectionHeaderTopPadding會有22個像素的高度。
if #available(iOS 15.0, *) {
self.tableView.sectionHeaderTopPadding = 0
}
3袁余,增加UISheetPresentationController擎勘,通過它可以控制 Modal 出來的 UIViewController 的顯示大小,且可以通過拖拽手勢在不同大小之間進行切換泌霍。
UISheetPresentationController *presentation = [UISheetPresentationController new];
// 顯示時支持的尺寸
presentation.detents = @[UISheetPresentationControllerDetent.largeDetent,UISheetPresentationControllerDetent.mediumDetent]
// 顯示一個指示器表示可以拖拽調整大小
presentation.prefersGrabberVisible = YES;
4货抄,推出CLLocationButton用于一次性定位授權,該內容內置于CoreLocationUI模塊朱转,但如果需要獲取定位的詳細信息仍然需要借助于CoreLocation蟹地。
5,URLSession 推出支持 async/await 的 API藤为,包括獲取數據怪与、上傳與下載。