iOS10-- snapshotViewAfterScreenUpdates 失效
如果snapshotViewAfterScreenUpdates失效, 用这个方法替代, 不过要自己创建ImageView 替代方式:
- (UIImage *)imageFromView:(UIView *)snapView { UIGraphicsBeginImageContext(snapView.frame.size); CGContextRef context = UIGraphicsGetCurrentContext(); [snapView.layer renderInContext:context]; UIImage *targetImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return targetImage; }
UIImage *image = [self imageFromView:fromVC.fromVCImageView]; UIImageView *snapView = [[UIImageView alloc] initWithImage:image]; snapView.frame = fromVC.fromVCImageView.frame; [containerView addSubview:snapView];