点击要切屏时点用此方法获取图片 image 极为切屏图片
- (UIImage *)captureImageFromView:(UIView *)view {
CGRect screenRect = [view bounds];
UIGraphicsBeginImageContext(screenRect.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[view.layer renderInContext:ctx];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
时间: 2024-11-05 20:07:34