如何保存 UIImage 或 UIImageView 的状态?
所以我让用户在我的自定义 TransformView 中转换 UIImage,它是 UIImageView 的子类。它允许用户使用touchesEnded、touchesMoved等来旋转、缩放和平移。现在我想做的就是将其从视图中删除并将其设置为当用户切换选项卡时为零。
如何保存图像的状态以便可以从同一位置再次加载?我希望它在屏幕上具有相同的缩放级别、旋转和位置。有什么想法吗?非常感谢!
So I've let the user transform a UIImage inside of my custom TransformView which is a subclassed UIImageView. It allows the user to rotate, scale, and pan using touchesEnded, touchesMoved, etc. Now what I'm trying to do, because my image is so large and takes up too much memory, is to remove it from view and set it to nil when the user switches tabs.
How do I save the state of the image so that it can load again from the same position? I want it to have the same zoom level, rotation, and position on screen. Any thoughts? Thanks so much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这取决于你如何进行转变。如果您使用 CATransform 进行这些操作,则图像更改不会影响它们。但如果您正在绘制上下文,那么您可能想要保存上下文。
It depends on how you did your transformations. If you were doing them using CATransform's them the image change won't affect them. But if you were drawing into context, then you probably want to save the context.