Tips:
iOS 16 真机调试时需要在设备的设置 —> 隐私与安全 —> 开发者模式中打开开发者模式。
适配内容:
新增控件内容
- UICalendarView 显示日期支持单选与多选
- UIPasteControl 读取剪贴板中的内容,跨 App 读取需要授权弹框
- UIEditMenuInteraction,取代 UIMenuController 和 UIMenuItem
- UIFindInteraction 用于文本内容查找与替换
- LARightStore 存储、获取 keychain 数据
- 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)
其他改动
- iOS 16 真机调试开启,
设置-隐私与安全-开发者模式
UIScreen.main
将会废弃,建议使用(UIApplication.shared.connectedScenes.first as? UIWindowScene)?.screen
- UISheetPresentationController 支持自定义显示的 UIViewController 的
大小
。 - UINavigationItem 改动
(新增属性style
描述UINavigationItem
在UINavigationBar
上的布局
(新增属性backAction
用于自定义 UIViewController 返回button事件
(新增属性titleMenuProvider
用于给当前导航栏的标题添加操作菜单 - UIPageControl 支持垂直显示、设置指示器、设置当前页图片。
- UITableView、UICollectionView 使用
Cell Content Configuration
时支持使用UIHostingConfiguration
包装 SwiftUI 代码定义 Cell 的内容。 - UITableView、UICollectionView 新增
selfSizingInvalidation
参数,使Cell可以自动调整大小 - UIMenu 支持尺寸
small
、medium
、large
. 例:UIMenu(title: “”, preferredElementSize: .small, children: menuElements) - UIDevice 获取设备信息时,只能获取设备的名称,隐私权限增强
- UIDevice 不再支持通过支持
setValue()
方法设置设备的方向,替换为 UIWindowScene 的requestGeometryUpdate()
方法。 - WidgetFamily 新增分类 accessory ,支持 iOS 锁屏显示和 watchOS 表盘显示