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 ?
try to imagine my abstraction as a "face down card fly from deck into its possition on boardView"
2
Answers
To help get you going…
First, no idea why you have your "deckPileImage" in a stack view, but assuming you have a reason for doing so…
a simple "card" view – bordered with rounded corners
a basic view controller – adds a "deck pile view" to a stack view, and a "card position view" as the destination for the new, animated cards.
It looks like this:
Each time you tap anywhere the code will add a new "card" and animate it from the "deck" view to the "card position" view.
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.
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.