SwiftUI is a revolutionary framework introduced by Apple that allows developers to build modern, declarative user interfaces with less code and more functionality. One of the most exciting features of SwiftUI is its built-in support for animations, making it easier than ever to create visually engaging iOS applications. Whether you’re aiming for subtle transitions or full-blown interactive motion, SwiftUI has tools to deliver seamless and smooth user experiences.

In this article, we will explore essential SwiftUI animation techniques for iOS, including implicit animations, explicit animations, transitions, custom animations, and gesture-driven effects.
1. Implicit Animations
Implicit animations are the simplest form of animation in SwiftUI. They automatically animate changes in view properties when wrapped inside the .animation()
modifier.
@State private var scale: CGFloat = 1.0 var body: some View { VStack { Circle() .scaleEffect(scale) .animation(.easeInOut(duration: 0.5), value: scale) Button("Animate") { scale += 0.2 } } }
In this example, tapping the button increases the scale of the circle with a smooth ease-in-out animation.
2. Explicit Animations
Explicit animations give developers more control by using withAnimation {}
closures to wrap state changes.
Button("Toggle") { withAnimation(.spring()) { isVisible.toggle() } }
Using this method, you can precisely control which properties animate and how.
3. View Transitions
SwiftUI provides transition modifiers like .transition(.slide)
or .transition(.opacity)
to animate view appearances and disappearances.
if showBox { Rectangle() .frame(width: 200, height: 200) .transition(.slide) }
This approach is useful for conditional views, especially in navigation, modal presentations, and list operations.
4. Animation Curves and Timing
SwiftUI supports different types of animation curves such as .linear
, .easeIn
, .easeOut
, .easeInOut
, and .spring()
to control the motion behavior.
.animation(.spring(response: 0.5, dampingFraction: 0.6), value: offset)
By tweaking parameters like damping and response, you can simulate real-world physics and enhance the UX.
5. Repeating and Delayed Animations
You can create infinite or repeated animations using .repeatForever()
and .repeatCount()
.
@State private var rotate = false Image(systemName: "arrow.2.circlepath") .rotationEffect(.degrees(rotate ? 360 : 0)) .animation(.linear(duration: 2).repeatForever(autoreverses: false), value: rotate) .onAppear { rotate = true }
This creates a looping rotation that mimics a loading spinner or refresh control.
6. Gesture-Based Animations
Combining animations with gestures provides interactive motion, improving user engagement.
@GestureState private var dragOffset = CGSize.zero Circle() .offset(dragOffset) .gesture( DragGesture() .updating($dragOffset) { value, state, _ in state = value.translation } ) .animation(.easeInOut, value: dragOffset)
Such animations react to user interaction and feel intuitive on touch devices.
7. Custom Animations and AnimatableData
For advanced use-cases, you can create custom animated views by conforming to the Animatable
protocol. This allows you to interpolate complex properties.
For example, creating a shape that animates between two paths or progress-based animations on custom components. To dive deeper, check out Apple’s official SwiftUI animation documentation for in-depth examples and advanced implementations.
Why Use SwiftUI for Animations?
- Declarative Syntax: Clean and readable code.
- Less Boilerplate: Easy state binding and animation integration.
- Smooth Transitions: Built-in animation curves and physics-based behaviors.
- Performance: Animations run on the GPU and are highly optimized for iOS.
Whether you’re working on a professional app or learning iOS development, mastering SwiftUI animation techniques will significantly enhance your user interface and help deliver a polished final product.