Created
July 10, 2015 23:50
-
-
Save algal/2fa41db7a5b61e366446 to your computer and use it in GitHub Desktop.
Save a UIImage into a URL
This file contains hidden or 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
/// Save image in an in-memory URL | |
func toURL(image:UIImage) -> NSURL | |
{ | |
let img = image | |
let imgData:NSData = UIImagePNGRepresentation(img) | |
let dataFormatString = "data:image/png;base64,%@" | |
let dataString = String(format: dataFormatString, imgData.base64EncodedStringWithOptions(.allZeros)) | |
let dataURL = NSURL(string: dataString)! | |
return dataURL | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment