|
https://www.hackingwithswift.com/books/ios-swiftui/building-custom-transitions-using-viewmodifier in this tutorial, when Paul comments the .clipped() method, we can se the red rectangle sliding in and out from the screen. But why when is sliding out it goes behind the blue rectangle first? and how could I make the red rectangle slide form the front to be able to see it sliding out from the screen? |
|
@igor has his logic back-to-front and seeks clarity:
Eat the elephantFirst break your big problem into smaller problems and solve them one at a time. Eat the big elephant one bite at a time. When you remove the To get a better grasp on this, run your code in the simulator, and select the Slow Animations menu item in the Debug menu. You'll notice how one view will start from the TOP of the screen then rotate clockwise into position. The other square will start in the normal position, but will rotate anti-clockwise from the bottom to the top of the screen. Eventually, it will disappear from the view. Why clockwise? (the next bite)Why does the view at the top of the screen turn clockwise? To do this it must start above its ending postion, and must rotate clockwise into position. Why anti-clockwise? (the next bite)Why does the view at the bottom of the screen turn anti-clockwise?
Take a look again at the Notice that after it gets to its final position, the square's animation is over, so it's no longer on the screen. It disappears. Why does the top square always rotate on TOP of the bottom square?This is a function of the Visualize!Here's some similar code. However I added a text box
Keep Coding!What's this about eating an elephant? Here's some links to my advice on eating elephants. See -> How to Eat an Elephant |
SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!
Sponsor Hacking with Swift and reach the world's largest Swift community!
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.