您的位置:首页 > 移动开发 > IOS开发

iOS10-- snapshotViewAfterScreenUpdates 失效

2016-09-19 16:02 941 查看
如果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];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: