dongwenbo

用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();

 

分类:

技术点:

相关文章:

  • 2022-01-24
  • 2022-12-23
  • 2022-12-23
  • 2021-10-16
  • 2018-03-29
  • 2018-07-20
  • 2021-12-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-09
  • 2022-12-23
  • 2021-05-27
  • 2021-06-12
  • 2022-01-08
相关资源
相似解决方案