只须要一个方法便可。图片
- (UIImage*) imageWithUIView:(UIView*) view{it
CGSize s = view.bounds.size;io
// 建立一个bitmap的contextmap
// 并把它设置成为当前正在使用的context方法
UIGraphicsBeginImageContextWithOptions(s, NO, [UIScreen mainScreen].scale);im
CGContextRef currnetContext = UIGraphicsGetCurrentContext();view
[view.layer renderInContext:currnetContext];vi
// 从当前context中建立一个改变大小后的图片co
UIImage* image = UIGraphicsGetImageFromCurrentImageContext();return
// 使当前的context出堆栈
UIGraphicsEndImageContext();
return image;
}