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];

 

posted @ 2016-09-19 16:02  ma_fighting  阅读(2358)  评论(2编辑  收藏  举报
历史天气查