美文网首页
返回一个给定view的截图

返回一个给定view的截图

作者: 冬的天 | 来源:发表于2016-08-12 14:45 被阅读0次

    - (UIView *)customSnapshotFromView:(UIView *)inputView {

    // Make an image from the input view.

    UIGraphicsBeginImageContextWithOptions(inputView.bounds.size, NO, 0);

    [inputView.layer renderInContext:UIGraphicsGetCurrentContext()];

    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    // Create an image view.

    UIView *snapshot = [[UIImageView alloc] initWithImage:image];

    snapshot.center = inputView.center;

    snapshot.layer.masksToBounds = NO;

    snapshot.layer.cornerRadius = 0.0;

    snapshot.layer.shadowOffset = CGSizeMake(-5.0, 0.0);

    snapshot.layer.shadowRadius = 5.0;

    snapshot.layer.shadowOpacity = 0.4;

    return snapshot;

    }

    相关文章

      网友评论

          本文标题:返回一个给定view的截图

          本文链接:https://www.haomeiwen.com/subject/rzfesttx.html