Lecture 6: Animation
Stanford Stanford
1.9M subscribers
51,500 views
0

 Published On Jun 1, 2020

Animation was the topic of lecture 6 of Stanford Spring 2020’s iOS Application Development course. After covering some ancillary topics like local, ephemeral state in Views (@State) and property observers, the lecture goes into a deep dive on animation, including implicit vs. explicit animations, transitions, Shape animations, animating ViewModifiers and more. These concepts are then installed in the Memorize demo by animating the flipping of cards, creating a new game and giving bonus points for quick matches.

In SwiftUI, any changes to ViewModifiers or Shapes can be animated. Views can animate changes either implicitly (using the animate declaration) or explicitly (by wrapping a withAnimation function call around code that might cause changes, most notably Intent functions in the ViewModel) and can control the duration and “curve” of the animation. The “arrival and departure” of Views on screen can also be animated using the transition declaration (which declares which ViewModifiers to use to draw Views before/after they arrive/depart from the screen). In Memorize, the Cardify ViewModifier and the Pie Shape are both made Animatable and animation is applied throughout.

show more

Share/Embed