简体   繁体   English

如何保存UIImage或UIImageView的状态?

[英]How do I save the state of a UIImage or UIImageView?

So I've let the user transform a UIImage inside of my custom TransformView which is a subclassed UIImageView. 因此,我让用户在我的自定义TransformView(它是UIImageView的子类)中转换UIImage。 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. 它允许用户使用touchesEnded,touchesMoved等进行旋转,缩放和平移。现在,由于我的图像太大且占用过多内存,我想做的是将其从视图中删除并将其设置为用户切换选项卡时为nil。

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! 非常感谢!

It depends on how you did your transformations. 这取决于您如何进行转换。 If you were doing them using CATransform's them the image change won't affect them. 如果您使用CATransform的图像进行更改,则图像更改不会影响它们。 But if you were drawing into context, then you probably want to save the context. 但是,如果要绘制上下文,则可能要保存上下文。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM