Created
August 24, 2016 10:10
-
-
Save bittz/edb8b53d4bcf924c8cee548182641fd2 to your computer and use it in GitHub Desktop.
UIImage from UIView.
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
import UIKit | |
extension UIImage { | |
static func imageFromView(view: UIView) -> UIImage { | |
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0) | |
view.drawViewHierarchyInRect(view.bounds, afterScreenUpdates: true) | |
let image = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() | |
return image | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment