#import <QuartzCore/QuartzCore.h>//记住要加上这个头文件!!! - (UIImage*)convertViewToUIImage:(UIView*)v { UIGraphicsBeginImageContext(v.bounds.size); CGContextRef currentContext = UIGraphicsGetCurrentContext(); [v.layer renderInContext:currentContext]; // 从当前context中创建一个改变大小后的图片 UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); // 使当前的context出堆栈 UIGraphicsEndImageContext(); return image; } 使用方法: UIView *view =[[UIView alloc]init]; UIImage *image = [self convertViewToUIImage:view];