Last active
August 29, 2015 14:20
-
-
Save motokiee/95a13b65c0c759d9f248 to your computer and use it in GitHub Desktop.
UIView Extension
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
/** | |
* xibからviewオブジェクトを取り出す | |
*/ | |
extension UIView { | |
class func loadFromNibNamed(nibNamed: String, bundle : NSBundle = NSBundle.mainBundle()) -> UIView! { | |
return UINib(nibName: nibNamed, bundle: bundle).instantiateWithOwner(nil, options: nil)[0] as? UIView | |
} | |
class func screenCapture(view: UIView) -> UIImage { | |
var captureImage: UIImage | |
UIGraphicsBeginImageContextWithOptions(view.frame.size, false, UIScreen.mainScreen().scale) | |
view.drawViewHierarchyInRect(view.bounds, afterScreenUpdates: true) | |
captureImage = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() | |
return captureImage | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment