objective-c - iOS:更改自身的内容(UIImage)

标签 objective-c ios uiimage cgcontextref

我在 UIImage 类别中编写了一些代码,该类别采用 UIImage(自身),然后使用 CGContextRef 重新绘制它。使用 CGBitmapContext 时有什么方法可以重写 UIImage (self) 吗?目前,我让它返回通过 CGContextRef 创建的图像,但是是否可以在该方法中重写图像本身?

最佳答案

来自 UIImage 文档:

Image objects are immutable, so you cannot change their properties after creation. ... Because image objects are immutable, they also do not provide direct access to their underlying image data.

因此,UIImage 创建后无法更改其图像数据。

关于objective-c - iOS:更改自身的内容(UIImage),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12062857/

相关文章:

ios - 动态创建的方法未被调用

ios - MPMoviePlayerController 在 Cocos2D 中导致约束警告

ios - Google Places API 未返回结果

ios - 任务恢复它无法正常运行 swift 3

swift - 创建可以使用图像作为填充的绘图应用程序的最佳方法

ios - 从缓冲区创建的 NSData 创建 UIImage 返回 nil?

ios - 如何创建自定义 UICollectionViewCell 并将来自 URL 的图像添加到它?

ios - 加载 View Controller 后的画外音顺序

objective-c - Xcode Outlet 生成不生成@synthesize

ios - 无法使用 tapGestureRecognizer 在屏幕上注册点击