返回一个给定view的截图

2016-08-12  本文已影响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;

}

上一篇 下一篇

猜你喜欢

热点阅读