View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • App Intents
    • Apple Intelligence
    • Games
    • Machine Learning & AI
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Vidéos

Ouvrir le menu Fermer le menu
  • Collections
  • Toutes les vidéos
  • À propos

Plus de vidéos

  • À propos
  • Code
  • Wind your way through advanced animations in SwiftUI

    Discover how you can take animation to the next level with the latest updates to SwiftUI. Join us as we wind our way through animation and build out multiple steps, use keyframes to add coordinated multi-track animated effects, and combine APIs in unique ways to make your app spring to life.

    Chapitres

    • 0:00 - Introduction
    • 2:23 - Animation phases
    • 8:12 - Keyframes
    • 15:07 - Tips and tricks

    Ressources

      • Vidéo HD
      • Vidéo SD

    Vidéos connexes

    WWDC23

    • Explore SwiftUI animation
    • What’s new in SwiftUI
  • Rechercher dans cette vidéo…
    • 0:42 - Scale Animation

      struct Avatar: View {
          var petImage: Image
          @State private var selected: Bool = false
      
          var body: some View {
              petImage
                  .scaleEffect(selected ? 1.5 : 1.0)
                  .onTapGesture {
                      withAnimation {
                          selected.toggle()
                      }
                  }
          }
      }
    • 3:13 - Boolean Phases

      OverdueReminderView()
                  .phaseAnimator([false, true]) { content, value in
                      content
                          .foregroundStyle(value ? .red : .primary)
                  } animation: { _ in
                      .easeInOut(duration: 1.0)
                  }
    • 6:20 - Custom Phases

      ReactionView()
          .phaseAnimator(
              Phase.allCases, 
              trigger: reactionCount
          ) { content, phase in
              content
                  .scaleEffect(phase.scale)
                  .offset(y: phase.verticalOffset)
          } animation: { phase in
              switch phase {
              case .initial: .smooth
              case .move: .easeInOut(duration: 0.3)
              case .scale: .spring(
                  duration: 0.3, bounce: 0.7)
              } 
          }
      
      enum Phase: CaseIterable {
          case initial
          case move
          case scale
      
          var verticalOffset: Double {
              switch self {
              case .initial: 0
              case .move, .scale: -64
              }
          }
      
          var scale: Double {
              switch self {
              case .initial: 1.0
              case .move: 1.1
              case .scale: 1.8
              }
          }
      }
    • 9:48 - Keyframes

      ReactionView()
          .keyframeAnimator(initialValue: AnimationValues()) { content, value in
              content
                  .foregroundStyle(.red)
                  .rotationEffect(value.angle)
                  .scaleEffect(value.scale)
                  .scaleEffect(y: value.verticalStretch)
                  .offset(y: value.verticalTranslation)
              } keyframes: { _ in
                  KeyframeTrack(\.angle) {
                      CubicKeyframe(.zero, duration: 0.58)
                      CubicKeyframe(.degrees(16), duration: 0.125)
                      CubicKeyframe(.degrees(-16), duration: 0.125)
                      CubicKeyframe(.degrees(16), duration: 0.125)
                      CubicKeyframe(.zero, duration: 0.125)
                  }
      
                  KeyframeTrack(\.verticalStretch) {
                      CubicKeyframe(1.0, duration: 0.1)
                      CubicKeyframe(0.6, duration: 0.15)
                      CubicKeyframe(1.5, duration: 0.1)
                      CubicKeyframe(1.05, duration: 0.15)
                      CubicKeyframe(1.0, duration: 0.88)
                      CubicKeyframe(0.8, duration: 0.1)
                      CubicKeyframe(1.04, duration: 0.4)
                      CubicKeyframe(1.0, duration: 0.22)
                  }
                  
                  KeyframeTrack(\.scale) {
                      LinearKeyframe(1.0, duration: 0.36)
                      SpringKeyframe(1.5, duration: 0.8, spring: .bouncy)
                      SpringKeyframe(1.0, spring: .bouncy)
                  }
      
                  KeyframeTrack(\.verticalTranslation) {
                      LinearKeyframe(0.0, duration: 0.1)
                      SpringKeyframe(20.0, duration: 0.15, spring: .bouncy)
                      SpringKeyframe(-60.0, duration: 1.0, spring: .bouncy)
                      SpringKeyframe(0.0, spring: .bouncy)
                  }
              }
      
      struct AnimationValues {
          var scale = 1.0
          var verticalStretch = 1.0
          var verticalTranslation = 0.0
          var angle = Angle.zero
      }
    • 15:22 - Map Keyframes

      struct RaceMap: View {
          let route: Route
      
          @State private var trigger = false
      
          var body: some View {
              Map(initialPosition: .rect(route.rect)) {
                  MapPolyline(coordinates: route.coordinates)
                      .stroke(.orange, lineWidth: 4.0)
                  Marker("Start", coordinate: route.start)
                      .tint(.green)
                  Marker("End", coordinate: route.end)
                      .tint(.red)
              }
              .toolbar {
                  Button("Tour") { trigger.toggle() }
              }
              .mapCameraKeyframeAnimation(trigger: playTrigger) { initialCamera in
                  KeyframeTrack(\MapCamera.centerCoordinate) {
                      let points = route.points
                      for point in points {
                          CubicKeyframe(point.coordinate, duration: 16.0 / Double(points.count))
                      }
                      CubicKeyframe(initialCamera.centerCoordinate, duration: 4.0)
                  }
                  KeyframeTrack(\.heading) {
                      CubicKeyframe(heading(from: route.start.coordinate, to: route.end.coordinate), duration: 6.0)
                      CubicKeyframe(heading(from: route.end.coordinate, to: route.end.coordinate), duration: 8.0)
                      CubicKeyframe(initialCamera.heading, duration: 6.0)
                  }
                  KeyframeTrack(\.distance) {
                      CubicKeyframe(24000, duration: 4)
                      CubicKeyframe(18000, duration: 12)
                      CubicKeyframe(initialCamera.distance, duration: 4)
                  }
              }
          }
      }
    • 16:26 - KeyframeTimeline

      // Keyframes
      let myKeyframes = KeyframeTimeline(initialValue: CGPoint.zero) {
          KeyframeTrack(\.x) {...}
          KeyframeTrack(\.y) {...}
      }
      
      // Duration in seconds
      let duration: TimeInterval = myKeyframes.duration
      
      // Value for time
      let value = myKeyframes.value(time: 1.2)

Developer Footer

  • Vidéos
  • WWDC23
  • Wind your way through advanced animations in SwiftUI
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning & AI
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • Security Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines