适配 iOS15

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,包括获取数据、上传与下载。

你可能感兴趣的:(适配 iOS15)