【发布时间】:2016-12-12 12:32:42
【问题描述】:
我通过调用[self.layer addSublayer:shapeLayer]; 将多个CAShapeLayers 添加到我的UIView 子类的layer 属性中
为了在UIImage 中捕获这些层,我实现了以下方法,该方法旨在获取layer 属性的图像。
- (UIImage *)takeImage {
UIGraphicsBeginImageContext(self.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
if (context) {
[self.layer renderInContext:context];
UIImage *snapshotImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return snapshotImage;
}
return nil;
}
我的问题是,生成的图像完全是空白的。为什么会这样?
【问题讨论】:
-
你有什么问题?
标签: uiimage core-graphics core-animation calayer cashapelayer