Evgeny Karkan
Evgeny Karkan

Reputation: 9612

How to animate UIImageView scale but keep its image unchanged?

I have a circle UIImageView with a user picture as an image.
I need to implement an animation - to make it possible to scale UIImageView down/up but keep its image unchanged.
I have tried the 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)

Upvotes: 0

Views: 1071

Answers (1)

picciano
picciano

Reputation: 22701

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.

Upvotes: 1

Related Questions