简体   繁体   中英

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!

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

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.

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