what's new in iOS 18 related to custom trait collection types
Generated on 7/30/2024
1 search

This post is brought to you by Tailscan,
the best devtool for Tailwind CSS.
In iOS 18, there are several new features related to custom trait collection types in UIKit:
-
Automatic Trait Tracking: UIKit now supports automatic trait tracking inside common view and view controller update methods such as
layoutSubviews
anddrawRect
. When these methods are called, UIKit records which traits you access. If any of those traits change, UIKit automatically performs the associated invalidation for that method, such as callingsetNeedsLayout
orsetNeedsDisplay
. This eliminates the need for manual trait change registration. For example, if you read the horizontal size class trait inlayoutSubviews
, UIKit will automatically callsetNeedsLayout
when the horizontal size class changes (What’s new in UIKit). -
List Environment Trait: Collection and table view APIs have been updated to include a new list environment trait set. This trait describes the style of the list that the view is in, ensuring that cells are styled appropriately. UI list content configuration and UI background configuration now take advantage of this new trait, adjusting their properties to match the list environment from the configuration state's trait collection (What’s new in UIKit).
-
New Constructors for UI Background Configuration: There are three new constructors for UI background configuration:
listCell
,listHeader
, andlistFooter
. These configurations automatically update their appearance based on the list environment trait, simplifying the code needed to manage different list styles (What’s new in UIKit).
These enhancements make it easier to manage and respond to trait changes in your app, improving performance and reducing the need for manual updates.

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

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.

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.

Elevate your tab and sidebar experience in iPadOS
iPadOS 18 introduces a new navigation system that gives people the flexibility to choose between using a tab bar or sidebar. The newly redesigned tab bar provides more space for content and other functionality. Learn how to use SwiftUI and UIKit to enable customization features – like adding, removing and reordering tabs – to enable a more personal touch in your app.