简体   繁体   中英

How to animate UIImageView scale but keep its image unchanged?

I have a circle UIImageView with user picture as image. I need to implement an animation - to make possible to scale UIImageView down/up but keep unchanged its image. I have tried following code:

[UIView animateWithDuration: 2.0f animations: ^{
        self.myImageView.transform = CGAffineTransformMakeScale(0.5f, 0.5f);
}];

But it changes the image scale too. I think this is expected behavior, so I need help - how to implement such kind of animation? (Scale only UIImageView and keep image unchanged)

You should animate myImageView.frame or myImageView.bounds instead. Be sure the contentMode is set to something that does not scale the image, such as top left or center.

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