XCode14 & iOS16 适配问题汇总

Tips:
iOS 16 真机调试时需要在设备的设置 —> 隐私与安全 —> 开发者模式中打开开发者模式。

适配内容:

新增控件内容

  1. UICalendarView 显示日期支持单选与多选
  2. UIPasteControl 读取剪贴板中的内容,跨 App 读取需要授权弹框
  3. UIEditMenuInteraction,取代 UIMenuController 和 UIMenuItem
  4. UIFindInteraction 用于文本内容查找与替换
  5. LARightStore 存储、获取 keychain 数据
  6. UIImage 新增的构造函数,支持 SF Symbols 新增的类别 Variable
lazy var pasteControl: UIPasteControl = {
       // 创建配置
       let config = UIPasteControl.Configuration()
       // 背景色
       config.baseBackgroundColor = .orange
       // 图标与文字颜色
       config.baseForegroundColor = .green
       // 形状
       config.cornerStyle = .capsule
       // 显示模式
       config.displayMode = .iconAndLabel
       // 创建UIPasteControl
       let pasteControl = UIPasteControl(configuration: config)
       // 设置target,获取剪切板内容后粘贴的位置
       pasteControl.target = textField
       pasteControl.frame = CGRect(x: 0, y: 0, width: 200, height: 60)
       pasteControl.center = view.center
       return pasteControl
   }()

//使用方法:在VC中添加control 

view.addSubview(pasteControl)


其他改动

  1. iOS 16 真机调试开启,设置-隐私与安全-开发者模式
  2. UIScreen.main将会废弃,建议使用 (UIApplication.shared.connectedScenes.first as? UIWindowScene)?.screen
  3. UISheetPresentationController 支持自定义显示的 UIViewController 的大小
  4. UINavigationItem 改动
    (新增属性 style 描述 UINavigationItemUINavigationBar上的布局
    (新增属性 backAction 用于自定义 UIViewController 返回button事件
    (新增属性 titleMenuProvider 用于给当前导航栏的标题添加操作菜单
  5. UIPageControl 支持垂直显示、设置指示器、设置当前页图片。
  6. UITableView、UICollectionView 使用 Cell Content Configuration 时支持使用 UIHostingConfiguration 包装 SwiftUI 代码定义 Cell 的内容。
  7. UITableView、UICollectionView 新增 selfSizingInvalidation 参数,使Cell可以自动调整大小
  8. UIMenu 支持尺寸 smallmediumlarge. 例:UIMenu(title: “”, preferredElementSize: .small, children: menuElements)
  9. UIDevice 获取设备信息时,只能获取设备的名称,隐私权限增强
  10. UIDevice 不再支持通过支持 setValue() 方法设置设备的方向,替换为 UIWindowScene 的requestGeometryUpdate() 方法。
  11. WidgetFamily 新增分类 accessory ,支持 iOS 锁屏显示和 watchOS 表盘显示

你可能感兴趣的:(Mac/iOS,ios,objective-c,xcode)