美文网首页
iOS 截屏并保存图片

iOS 截屏并保存图片

作者: 微笑不是你 | 来源:发表于2017-11-05 09:47 被阅读0次

在应用内截取屏幕

- (UIImage *)captureImageFromView:(UIView *)view{

CGRect screeRect = [view bounds];

UIGraphicsBeginImageContext(screeRect.size);

CGContextRef ctx = UIGraphicsGetCurrentContext();

[view.layer renderInContext:ctx];

UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return image;

}

保存图片在本地相册中

UIImage *image = [self captureImageFromView:self.view];

UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);

相关文章

网友评论

      本文标题:iOS 截屏并保存图片

      本文链接:https://www.haomeiwen.com/subject/wwdcmxtx.html