用Quartz2D
1 CGSize imageSize = self.view.bounds.size; 2 //开启图形上下文 3 UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0); 4 //获得图形上下文 5 CGContextRef context = UIGraphicsGetCurrentContext(); 6 //将View渲染到图形上下文 7 [self.view.layer renderInContext:context]; 8 //从上下文中取得图像 9 UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 10 11 UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil); 12 //切割图片 13 CGImageRef subimageRef = CGImageCreateWithImageInRect(image.CGImage, CGRectMake(0, 0, 320, 320)); 14 UIImage *subImage1 = [UIImage imageWithCGImage:subimageRef]; 15 16 UIImageWriteToSavedPhotosAlbum(subImage1, nil, nil, nil); 17 18 UIGraphicsEndImageContext();