How do you synchronize metal animation with uikit animations?
Asked on 08/09/2024
1 search
To synchronize Metal animations with UIKit animations, you can leverage the new APIs introduced in iOS 18 that enhance the interoperability between SwiftUI and UIKit. Specifically, you can use SwiftUI animation types to animate UIKit views, ensuring that animations run perfectly in sync across framework boundaries.
Here are the steps to achieve this:
-
Use SwiftUI Animation Types: You can now use SwiftUI animation types to animate UIKit views. This allows you to take advantage of the full suite of SwiftUI animations, including custom animations.
-
Bridge Animations: Utilize the new
animate
function onUIView
andNSAnimationContext
to bridge animations started in SwiftUI into UIKit. This ensures that animations run in sync even across different frameworks. -
Preserve Velocity: For gesture-driven animations, SwiftUI automatically preserves velocity, which can be beneficial for creating fluid animations that respond to user interactions.
For a detailed explanation and examples, you can refer to the session Enhance your UI animations and transitions (11:19).
Relevant Sessions
These sessions provide comprehensive insights into the new animation capabilities and how to effectively synchronize animations across different frameworks.

Platforms State of the Union
Discover the newest advancements on Apple platforms.

Enhance your UI animations and transitions
Explore how to adopt the zoom transition in navigation and presentations to increase the sense of continuity in your app, and learn how to animate UIKit views with SwiftUI animations to make it easier to build animations that feel continuous.

What’s new in UIKit
Explore everything new in UIKit, including tab and document launch experiences, transitions, and text and input changes. We’ll also discuss better-than-ever interoperability between UIKit and SwiftUI animations and gestures, as well as general improvements throughout UIKit.