Created
April 17, 2018 03:53
-
-
Save gilbox/87ddb29ac96687eea8488fbcb99c0252 to your computer and use it in GitHub Desktop.
Copy UIImage
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
class ImageUtils { | |
static func copiedImage(_ image: UIImage) -> UIImage? { | |
UIGraphicsBeginImageContext(image.size) | |
image.draw(in: CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height)) | |
guard let copy = UIGraphicsGetImageFromCurrentImageContext() else { return nil } | |
UIGraphicsEndImageContext() | |
return copy | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment