替换下即可
UIImage *YBIBSnapshotView(UIView *view) {
- UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, [UIScreen mainScreen].scale);
- [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:NO];
- UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
+ CGSize size = view.bounds.size;
+ UIGraphicsImageRendererFormat *format = [[UIGraphicsImageRendererFormat alloc] init];
+ format.scale = [UIScreen mainScreen].scale;
+ UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:size format:format];
+ UIImage *image = [renderer imageWithActions:^(UIGraphicsImageRendererContext * _Nonnull rendererContext) {
+ }];
return image;
}