iOS 照片编辑与相机使用指南
1. 照片修改与实时照片编辑
当用户点击“修改”时,会进行相应修改。若正在显示图像,需切换到主线程重新显示:
PHPhotoLibrary.shared().performChanges {
typealias Req = PHAssetChangeRequest
let req = Req(for: self.asset)
req.contentEditingOutput = output // triggers alert
} completionHandler: { ok, err in
if ok {
// if we are displaying the image, redisplay it on the main thread
} else {
// user refused to allow modification, do nothing
}
}
也可以使用 PHLivePhotoEditingContext 编辑实时照片,系统会将视频的每一帧作为 CIImage 提供,便于应用 CIFilter 。若需演示,可参考 Apple 的 Photo Edit 示例应用。
2. 照片编辑扩展
照片编辑扩展是应用提供的用于修改照片的代码,会被有效注入到 Photos 应用中。当用户在 Photos 应用内编辑照片时,扩展会作为一个选项出现,并可对正在编
超级会员免费看
订阅专栏 解锁全文
42

被折叠的 条评论
为什么被折叠?



