//获取屏幕截屏方法
- (UIImage *)capture
{

    // 创建一个context
    UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);

    //把当前的全部画面导入到栈顶context中并进行渲染
    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];

    // 从当前context中创建一个新图片
    UIImage * img = UIGraphicsGetImageFromCurrentImageContext();

    // 使当前的context出堆栈
    UIGraphicsEndImageContext();

    return img;
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
  • 2022-01-23
  • 2022-12-23
  • 2021-05-20
  • 2021-10-16
  • 2021-05-17
猜你喜欢
  • 2021-09-15
  • 2022-12-23
  • 2022-02-10
  • 2022-12-23
  • 2021-08-03
  • 2021-08-06
相关资源
相似解决方案