what's changed in swiftui
Generated on 8/2/2024
1 search
What's Changed in SwiftUI
SwiftUI has seen several significant updates and enhancements this year. Here are some of the key changes:
-
Graphics Capabilities:
- Color Mixing: A new
mix
modifier onColor
allows blending colors together by a given amount. - Custom Shaders: Extended to allow precompiling shaders before their first use, avoiding frame drops caused by lazy shader compilation.
- Color Mixing: A new
-
Scroll View Enhancements:
- Fine-Grained Control: New APIs provide more control over scroll views, including reacting to changes in content, offsets, and content size.
- Visibility Detection: Detect when a view's visibility changes due to scrolling, enabling experiences like auto-playing videos.
- Scroll Positions: More scroll positions to programmatically scroll to, such as the top edge.
- Additional Customizations: Options to turn off bouncing along a given axis, programmatically stop scrolling, and control content alignment.
-
Swift 6 Language Mode:
- Compile-Time Data Race Safety: The new Swift 6 language mode enables compile-time data race safety.
- Main Actor Annotation: Views in SwiftUI are now marked with the
@MainActor
annotation, meaning all types conforming toView
are implicitly isolated to the main actor by default.
-
Interoperability:
- UIKit and AppKit Integration: Improved integration with UIKit and AppKit, including the ability to use SwiftUI animations and gesture recognizers with UIKit views.
- Gesture Recognition: Gesture recognition has been factored out of UIKit, allowing built-in or custom UI gesture recognizers to be used in SwiftUI view hierarchies.
-
Accessibility:
- Enhanced Accessibility Labels: Add additional accessibility information to controls without overriding the framework-provided label.
- Conditional Modifier Support: New accessibility features such as conditional modifier support and app intent-based accessibility actions.
-
Xcode Previews:
- Dynamic Linking Architecture: Allows switching between a preview and build and run without needing to rebuild the project, increasing iteration speed.
- State in Previews: Use state directly in previews using the
@Previewable
macro, eliminating the need for boilerplate code.
-
Text and Selection Management:
- Programmatic Text Selection: New ways to work with text and manage selection, including programmatic access to and control of text selection within text editing controls.
-
Custom Containers and Mesh Gradients:
- Custom Containers: New features for creating custom containers.
- Mesh Gradients: Support for mesh gradients to create more complex and visually appealing designs.
For a detailed overview, you can watch the session What’s new in SwiftUI starting at 15:56.
SwiftUI essentials
Join us on a tour of SwiftUI, Apple’s declarative user interface framework. Learn essential concepts for building apps in SwiftUI, like views, state variables, and layout. Discover the breadth of APIs for building fully featured experiences and crafting unique custom components. Whether you’re brand new to SwiftUI or an experienced developer, you’ll learn how to take advantage of what SwiftUI has to offer when building great apps.
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.
What’s new in SwiftUI
Learn how you can use SwiftUI to build great apps for any Apple platform. Explore a fresh new look and feel for tabs and documents on iPadOS. Improve your window management with new windowing APIs, and gain more control over immersive spaces and volumes in your visionOS apps. We’ll also take you through other exciting refinements that help you make expressive charts, customize and layout text, and so much more.
Platforms State of the Union
Discover the newest advancements on Apple platforms.