showtimefan
showtimefan

Reputation: 47

How to animate from UiImageView to a UIView

I use Path2.0. I have found that when I click the small picture in a message,there would be an animation to show the whole picture. How does it do that? I would really appreciate help here. Thanks!

Upvotes: 1

Views: 257

Answers (2)

Alan Zeino
Alan Zeino

Reputation: 4396

I doubt they modify the original UIImageView; but a solution might be:

  1. Copy the UIImageView (or UIImage)
  2. Add it as a subview with the same exact frame as the original image
  3. Apply a scale transform on the UIImageView (by using the CGAffineTransformMakeScale() function on a UIView's transform property (inside a UIView animation block)
  4. Then instantiate the root window with a scaled version of the full image

Alternatively, you could instantiate the new subview with the full image, set it with the original UIImageView's frame, and then (using a UIView animation block), set it to the newer frame. To match their implementation exactly, I suggest a black subview (of the full UIImageView) with an alpha of 0.0 that you then animate at the same duration to an alpha of 1.0.

Upvotes: 0

Chris Chen
Chris Chen

Reputation: 5407

UiImageView is bascially a UIView, which you can apply animation on.

The use case you want to achieve combines:

a. a response to touch event, which you can use UITapGestureRecoginizer to attache a block of code

b. zoom the UIImageView into a proper size and position, you can use UIView's class method AnimiationWithDuration....

c. Ultimately, you want to change your UIImageView's frame property to a larger one. use CGRectMake to generate a new one. If you need to take the whole screen estate (like Path 2.0 does), you may need [UIApplication sharedApplication].window for this

Upvotes: 1

Related Questions