- (UIImage*) imageWithUIView:(UIView*) view{
//创建一个bitmap的context
//并把它设置成为当前正在使用的context
UIGraphicsBeginImageContext(CGSizeMake(view.bounds.size.width, view.bounds.size.height));
CGContextRefcurrnetContext =UIGraphicsGetCurrentContext();
[view.layerrenderInContext:currnetContext];
//从当前context中创建一个改变大小后的图片
UIImage* image =UIGraphicsGetImageFromCurrentImageContext();
//使当前的context出堆栈
UIGraphicsEndImageContext();
returnimage;
}
网友评论