iOS 15 UI适配

2023-03-07,,

1. UINavigationBar

iOS 15中,UINavigationBar默认为透明。在滑动时会有模糊效果。如果想要一直就是模糊效果,可以通过改变scrollEdgeAppearance属性来实现。

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 增加一个默认高度,当我们使用 UITableViewStylePlain 初始化UITableView 的时候,系统默认给 section header 增高了22像素。

if (@available(iOS 15.0, *)) {
tableView.sectionHeaderTopPadding = 0;
}

 

iOS 15 UI适配的相关教程结束。

《iOS 15 UI适配.doc》

下载本文的Word格式文档,以方便收藏与打印。