【发布时间】:2017-09-13 12:25:32
【问题描述】:
我想将 UIView 的快照作为 PNG 图像。在我的情况下,视图具有圆角,因此,当我拍摄快照时,它会显示边缘为圆形的黑色。我希望它是透明的。我怎样才能做到这一点?
这是我用来获取图像的代码。
- (UIImage *)snapshotOfQuoteContainerView {
UIGraphicsBeginImageContextWithOptions(self.outerContainerView.bounds.size, YES, 0.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
[self.outerContainerView.layer renderInContext:context];
UIImage *snapshotImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return snapshotImage;
}
注意:After changing image size, image's transparent part became black 没有解决我的问题。就我而言,它与更改图像大小无关。
【问题讨论】:
-
显示。您的。代码。
-
代码在哪里?
-
添加源代码。
-
显示您的 outerContainerView 属性。你设置 UIView 的 "clipsToBound=YES" 属性了吗?
-
是,设置为是。我也试过没有。它没有帮助。