What new SwiftUI apis are available?

Generated on 7/31/2024

1 search

Tailscan

This post is brought to you by Tailscan, the best devtool for Tailwind CSS.

New SwiftUI APIs

Graphics Capabilities

  • Color Mixing: A new mix modifier on Color allows blending with another color by a given amount.
  • Custom Shaders: Extended to allow precompiling shaders before their first use to avoid frame drops.

Scroll View Enhancements

  • On Scroll Geometry Change: React to changes in content, offsets, content size, etc.
  • Visibility Detection: Detect when a view's visibility changes due to scrolling.
  • Scroll Positions: More programmatic control over scroll positions, including scrolling to the top edge.
  • Additional Controls: Options to turn off bouncing along a given axis, programmatically stop scrolling, and control content alignment.

Accessibility

  • 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.

Text and Selection

  • Text Selection: Programmatic access to and control of text selection within text editing controls.

Xcode Previews

  • Dynamic Linking Architecture: Switch between preview and build/run without needing to rebuild the project.
  • Previewable Macro: Use state directly in previews, eliminating boilerplate code.

Custom Containers and Mesh Gradients

  • Custom Containers: New APIs for creating custom containers.
  • Mesh Gradients: Beautiful mesh gradients for more dynamic UI designs.

Interoperability

  • Gesture Recognition: Use any built-in or custom UI gesture recognizer in SwiftUI view hierarchy.
  • Animations: Set up animations on UIKit or AppKit views and drive them with SwiftUI, including fully custom animations.

Swift 6 Language Mode

  • Compile Time Data Race Safety: New language mode for compile-time data race safety.
  • Main Actor Annotation: Views in SwiftUI are now marked with the main actor annotation by default.

Additional Customizations

  • Custom Hover Effects: For visionOS, providing additional context when interacting with UI elements.
  • Window Behavior and Styling: Customize window behavior and styling in macOS, including control over the Windows toolbar and background.
  • Text Renderer API: New API for advanced visual effects and playful animations.

For a detailed overview, you can watch the session What’s new in SwiftUI.