#import <QuartzCore/QuartzCore.h>
@property (retain, nonatomic) IBOutlet UIImageView *imageView;
-(UIImage*)getShot
{
UIGraphicsBeginImageContext(CGSizeMake(320, 460));
[imageView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return viewImage;
}
本文介绍如何利用QuartzCore框架从一个UIImageView中获取截图,并返回为UIImage对象。通过UIGraphicsBeginImageContext和UIGraphicsGetCurrentContext进行图像上下文渲染,最终得到所需的屏幕截图。
2320

被折叠的 条评论
为什么被折叠?



