IOS 实现截图功能
-(UIImage *)saveImage:(UIView *)view withRect:(CGRect) mainRect // mainRect 应该是相对于屏幕的Rect
{
UIGraphicsBeginImageContext(mainRect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[[UIColor blackColor] set];
CGContextFillRect(context, mainRect);
[view.layer renderInContext:context];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
posted on 2014-01-23 15:35 MoreNotepad++ 阅读(93) 评论(0) 收藏 举报
浙公网安备 33010602011771号