Last active
November 4, 2016 02:35
-
-
Save endodoug/1545900d275c171e79c491787098c789 to your computer and use it in GitHub Desktop.
Save Photo to Library - Swift 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func savePhotoToLibrary(image: UIImage) { | |
let photoLibrary = PHPhotoLibrary.shared() | |
photoLibrary.performChanges({ | |
PHAssetChangeRequest.creationRequestForAsset(from: image) | |
}) { (success: Bool, error: Error?) -> Void in | |
if success { | |
// Set thumbnail | |
self.setPhotoThumbnail(image: image) | |
} else { | |
print("Error writing to photo library: \(error!.localizedDescription)") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment