[英]How do I replace an image in a rotated and scaled UIImageView?
I have a UIView
with a UIImageView
as a subview
. 我有一个UIView
, UIImageView
作为subview
。 I modify the UIView
with CGAffineTransformRotate
and CGAffineTransformScale
. 我用CGAffineTransformRotate
和CGAffineTransformScale
修改了UIView
。 The UIImageView
subview
also transforms with it automatically. UIImageView
subview
也会自动转换。
I want to replace the UIImage
in the UIImageView
subview
with a new UIImage
. 我想更换UIImage
中UIImageView
subview
用新UIImage
。 When I do this, the image
is the wrong size and rotation
, because the original been scaled and rotated. 当我这样做时, image
的大小和rotation
是错误的,因为原始缩放和旋转。
How do I replace the image subview
and have it appear as the previous image
did (same size/rotation/location) ? 如何替换图像subview
并使其显示为上一image
(相同大小/旋转/位置) ?
Take another UIImageView2 and put your previous image in it first. 取另一个UIImageView2并将您之前的图像放入其中。 Then after you scale and modify the original image to a new one and want to see your original one, you can show the UIImageView2 image. 然后,在将原始图像缩放并修改为新图像并想要查看原始图像之后,可以显示UIImageView2图像。
I found the bug, I was removing the original image and didn't know it. 我发现了这个错误,我正在移除原始图像并且不知道它。
imageView.image = nextImage;
Changing the image as above keeps the scale and rotation from the parent. 如上所述更改图像可保持父级的缩放和旋转。 No trickery involved. 没有任何诡计。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.