導(dǎo)航欄
從 iOS 15 開始,UINavigationBar、UIToolbar 和 UITabBar 在控制器中關(guān)聯(lián)滾動視圖頂部或底部時使用UINavigationBar.scrollEdgeAppearance配置相關(guān)屬性-背景、字體等
if #available(iOS 15.0, *) { //UINavigationBarAppearance屬性從iOS13開始
let navBarAppearance = UINavigationBarAppearance()
// 背景色
navBarAppearance.backgroundColor = UIColor.clear
// 去掉半透明效果
navBarAppearance.backgroundEffect = nil
// 去除導(dǎo)航欄陰影(如果不設(shè)置clear,導(dǎo)航欄底下會有一條陰影線)
navBarAppearance.shadowColor = UIColor.clear
// 字體顏色
navBarAppearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
self.navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
}
TableView
從 iOS 15 開始,TableView 增加sectionHeaderTopPadding屬性,默認(rèn)情況sectionHeaderTopPadding會有22個像素的高度,及默認(rèn)情況,TableView section header增加22像素的高度
/// Padding above each section header. The default value is `UITableViewAutomaticDimension`.
@available(iOS 15.0, *)
open var sectionHeaderTopPadding: CGFloat
if #available(iOS 15.0, *) {
self.tableView.sectionHeaderTopPadding = 0
}