0Pricing
Swift Academy · Lesson

Implicit vs Explicit Animations

Using .animation() modifier vs withAnimation {} block for different use cases.

Two Animation Styles

SwiftUI supports implicit animations (the .animation modifier) and explicit animations (the withAnimation closure).

struct Demo: View {
  @State private var scale = 1.0
  var body: some View {
    Circle().scaleEffect(scale)
  }
}

Implicit Animation with .animation

Attaching .animation(_:value:) to a view animates it whenever the bound value changes.

Circle()
  .scaleEffect(scale)
  .animation(.easeInOut(duration: 0.3), value: scale)

All lessons in this course

  1. Implicit vs Explicit Animations
  2. matchedGeometryEffect for Hero Transitions
  3. Custom AnimatableModifier and Animatable
  4. TimelineView and Canvas for High-Performance Drawing
← Back to Swift Academy