简体   繁体   中英

How do I replace an image in a rotated and scaled UIImageView?

I have a UIView with a UIImageView as a subview . I modify the UIView with CGAffineTransformRotate and CGAffineTransformScale . The UIImageView subview also transforms with it automatically.

I want to replace the UIImage in the UIImageView subview with a new UIImage . When I do this, the image is the wrong size and rotation , because the original been scaled and rotated.

How do I replace the image subview and have it appear as the previous image did (same size/rotation/location) ?

Take another UIImageView2 and put your previous image in it first. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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