100 Days of SwiftUI

Day 32

2026-05-20

Project 6, part one

Learning about animations — ways to bring our app to life.

Animation: Introduction

Besides making our apps look more interesting, animations can give users clues to what’s going on with the program

Creating implicit animations

  • simplest type of animation
  • scaleEffect() changes the scale of the view — 1 is the normal size
  • using a negative number on scaleEffect() rotates the view 180° (not flipped, because it’s not mirror text)

Customizing animations in SwiftUI

  • can specify the type of animation — .default is a gentle spring; .linear is boring
  • need to supply a value: for .animation to track otherwise it will happen whenever something happens to the view (like rotating your phone)
  • also .spring, .easeInOut have duration, can be delayed, repeated (even forever!), etc
  • .overlay is useful for combining effects

Animating bindings

  • animation() can be applied to bindings, which makes the animation go between its current and new values
    • including Bools!
  • you can attach the animation directly to a $boundValue

Creating explicit animations

  • want to animate (something) when there is an arbitrary state change
    • not attached to a View or $binding
  • to make Swift wait until there’s a particular state change, use the withAnimation {} function

SO MUCH SYNTAX! How am I supposed to learn what I can do? The Apple developer docs are not exactly newb-friendly.