Created
April 11, 2014 07:47
-
-
Save Bayonetta/10447654 to your computer and use it in GitHub Desktop.
view convert to image
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
- (UIImage*) imageWithUIView:(UIView*) view{ | |
// 创建一个bitmap的context | |
// 并把它设置成为当前正在使用的context | |
UIGraphicsBeginImageContext(view.bounds.size); | |
CGContextRef currnetContext = UIGraphicsGetCurrentContext(); | |
//[view.layer drawInContext:currnetContext]; | |
[view.layer renderInContext:currnetContext]; | |
// 从当前context中创建一个改变大小后的图片 | |
UIImage* image = UIGraphicsGetImageFromCurrentImageContext(); | |
// 使当前的context出堆栈 | |
UIGraphicsEndImageContext(); | |
return image; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment