var localID = ""
PHPhotoLibrary.shared().performChanges {
let result = PHAssetChangeRequest.creationRequestForAsset(from: image)
let assetPlaceholder = result.placeholderForCreatedAsset
localID = assetPlaceholder?.localIdentifier ?? "" // 保存保存标志符
} completionHandler: { (success, error) in
if success == true {
NSLog("保存成功")
//通过标志符获取对应的资源
let assetResult = PHAsset.fetchAssets(withLocalIdentifiers: [localID], options: nil)
let asset = assetResult.firstObject
let options = PHContentEditingInputRequestOptions()
options.canHandleAdjustmentData = {(adjustmeta: PHAdjustmentData) -> Bool in
return true
}
//获取保存的图片路径
asset?.requestContentEditingInput(with: options, completionHandler: { (contentEditingInput, info) in
let uri = contentEditingInput?.fullSizeImageURL?.absoluteString ?? ""
ImageUri(uri)
})
} else {
NSLog("保存失败: \(String(describing: error?.localizedDescription))")
}
}