如何在图库中重命名/保存图像

时间:2018-02-01 05:41:20

标签: ios swift photo-gallery photolibrary

我创建了一个自定义文件夹,通过我的应用程序将图像保存在库中(实现了如下代码)。现在我想为保存的图像设置自定义名称。我怎样才能实现这一挑战?如果有人可以帮助我实现这一挑战。

func save(image: UIImage, strName : String) {

        self.checkAuthorizationWithHandler { (success) in
            if success, self.assetCollection != nil {
                PHPhotoLibrary.shared().performChanges({
                    let assetChangeRequest = PHAssetChangeRequest.creationRequestForAsset(from: image)
                    let assetPlaceHolder = assetChangeRequest.placeholderForCreatedAsset
                    let albumChangeRequest = PHAssetCollectionChangeRequest(for: self.assetCollection)
                    let enumeration: NSArray = [assetPlaceHolder!]
                    albumChangeRequest!.addAssets(enumeration)

                }, completionHandler: nil)
            }
        }
    }

0 个答案:

没有答案