本文介绍了来自CALayer的CGImage(或UIImage)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个 CALayer (我在图层中添加了几个形状,但最终我有一个CALayer),而且我有很多把它添加到CGImage的麻烦。我找到了一些 [CALayer renderInContext:ctx] 的引用,但我不确定如何实现它。
I have created a CALayer (I added several shapes to the layer, but ultimately, I have a single CALayer), and I am having a LOT of trouble adding it to a CGImage. I have found some references to [CALayer renderInContext:ctx], but I am not sure how to implement it.
之前有没有人这样做过?
Has anyone done this before?
推荐答案试试这个......
Try this...
UIGraphicsBeginImageContext(layer.bounds.size); [layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();更多推荐
来自CALayer的CGImage(或UIImage)
发布评论