Last active
August 29, 2015 14:04
-
-
Save molon/6523ffb8d8feaf28d493 to your computer and use it in GitHub Desktop.
capture for UIScrollView
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
| - (UIImage*)image | |
| { | |
| UIImage *image = nil; | |
| UIGraphicsBeginImageContextWithOptions(self.contentSize, NO, 0.0f); | |
| { | |
| CGPoint origOffset = self.contentOffset; | |
| CGRect origFrame = self.frame; | |
| self.frame = CGRectMake(0, 0, self.contentSize.width, self.contentSize.height); | |
| self.contentOffset = CGPointZero; | |
| [self.layer renderInContext:UIGraphicsGetCurrentContext()]; | |
| image = UIGraphicsGetImageFromCurrentImageContext(); | |
| self.frame = origFrame; | |
| self.contentOffset = origOffset; | |
| } | |
| UIGraphicsEndImageContext(); | |
| return image; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment