Skip to content

Instantly share code, notes, and snippets.

@gilbox
Created April 17, 2018 03:53
Show Gist options
  • Save gilbox/87ddb29ac96687eea8488fbcb99c0252 to your computer and use it in GitHub Desktop.
Save gilbox/87ddb29ac96687eea8488fbcb99c0252 to your computer and use it in GitHub Desktop.
Copy UIImage
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