What is new in SwiftUI for iOS 17 and 18?

Generated on 8/6/2024

1 search

Tailscan

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

What's New in SwiftUI for iOS 17 and 18

iOS 17

For iOS 17, SwiftUI introduced several new features and improvements:

  1. Graphics Capabilities: New mix modifier on color to blend colors by a given amount.
  2. Custom Shader Feature: Ability to precompile shaders before their first use to avoid frame drops.
  3. Scroll View Enhancements:
    • Fine-grained control over scroll views.
    • New onScrollGeometryChange to react to changes in content, offsets, and content size.
    • Detecting view visibility changes due to scrolling.
    • More programmatic control over scroll positions and content alignment.
  4. Swift 6 Language Mode:
    • Compile-time data race safety.
    • Views in SwiftUI are now marked with the @MainActor annotation by default.

For more details, you can refer to the session What’s new in SwiftUI (16:47).

iOS 18

For iOS 18, SwiftUI continued to evolve with additional features:

  1. TabView Enhancements:
    • New syntax to catch common errors at build time.
    • Declaration of a tab struct with title, image, and content view.
    • Programmatic selection of tabs.
  2. Interoperability with UIKit:
    • Gesture recognition factored out of UIKit, enabling use in SwiftUI view hierarchy.
    • Animations factored out of SwiftUI, allowing setup on UIKit or AppKit views and driven by SwiftUI.
  3. Custom Containers and Mesh Gradients:
    • New custom containers and mesh gradients for more flexible UI designs.
  4. Scrolling Customizations:
    • Additional knobs for perfecting the scrolling experience, such as turning off bouncing along a given axis and programmatically stopping scrolling.

For more details, you can refer to the session What’s new in SwiftUI (00:07).

Relevant Sessions

These sessions provide a comprehensive overview of the new features and improvements in SwiftUI for iOS 17 and 18.