如何从 UIView 的内容中获取 CGImageRef?
我有一个 UIView,我在 -drawRect: 中画了一些东西。现在我需要来自 UIView 的图形上下文或位图的 CGImageRef。有没有一种简单的方法可以做到这一点?
I have an UIView where I was drawing some stuff inside -drawRect:. Now I need a CGImageRef from this graphics context or bitmap of the UIView. Is there an easy way to get that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
斯威夫特5
Swift 5
像这样(凭记忆输入,所以可能不是 100% 正确):
Like this (typed from memory, so it might not be 100% correct):
另请确保将
#import
添加到代码中
Also make sure that you add
#import <QuartzCore/QuartzCore.h>
to your code