Home > front end >  How to animate movement of UIView between different superViews
How to animate movement of UIView between different superViews

Time:05-20

Hello I am new at swift and IOS apps , I am trying to animate movement of cardBackImage (UIImage) from deckPileImage to the card view, but everything got different superViews and I have no idea how to do it properly , all the location have different frames ( superviews as described in the Image) , Should I use CGAffineTransform ?

enter image description here

Each time you tap anywhere the code will add a new "card" and animate it from the "deck" view to the "card position" view.

enter image description here enter image description here enter image description here

CodePudding user response:

Don't animate the view at all. Instead, animate a snapshot view as a proxy. You can see me doing it here, in this scene from one of my apps.

enter image description here

That red rectangle looks like it's magically flying out of one view hierarchy into another. But it isn't. In reality there are two red rectangles. I hide the first rectangle and show the snapshot view in its place, animate the snapshot view to where the other rectangle is lurking hidden, then hide the snapshot and show the other rectangle.

  • Related