What's the difference between the updateProperties method introduced and the viewWillLayoutSubviews introduced for Observation tracking in UIKit? Which should be used in what context?
Asked on 06/11/2025
1 search
The updateProperties
method and viewWillLayoutSubviews
serve different purposes in UIKit, particularly with the introduction of automatic observation tracking.
updateProperties
Method
- Purpose: It is a new method introduced to support automatic trait and observation tracking. It allows you to update properties without forcing a layout, providing finer-grained updates.
- Usage: Use
updateProperties
to populate content, apply styling, or configure behaviors. It automatically tracks any observable you read, and you can manually trigger it by callingsetNeedsUpdateProperties
. - Timing: It runs just before
layoutSubviews
but is independent of it, allowing you to invalidate properties without triggering a layout pass. - Example: If you have an observable model object, changes to this model will trigger
updateProperties
, allowing you to update the view accordingly without unnecessary layout passes.
viewWillLayoutSubviews
- Purpose: This method is part of the traditional layout cycle in UIKit, used to make changes just before the layout of subviews.
- Usage: Use
viewWillLayoutSubviews
when you need to adjust the layout of subviews in response to changes in the view's bounds or other layout-related changes. - Timing: It is called during the layout pass, after
updateProperties
has been executed.
When to Use Each
- Use
updateProperties
when you need to update properties based on observable changes without affecting the layout. It is ideal for updating content or styles that do not require a layout pass. - Use
viewWillLayoutSubviews
when you need to adjust the layout of subviews in response to changes in the view's size or other layout-related events.
For more details, you can refer to the session What’s new in UIKit (12:30) where these methods are discussed.

What’s new in UIKit
Modernize your app with the latest APIs in UIKit, including enhanced menu bar support, automatic observation tracking, a new UI update method, and improvements to animations. We’ll also cover how you can include SwiftUI scenes in your UIKit app and explore SF Symbols, HDR color pickers, and 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.

What’s new in Swift
Join us for an update on Swift. We’ll talk about workflow improvements that make you more productive, and new and modernized library APIs for fundamental programming tasks. We’ll show examples of Swift adoption throughout more layers of the software stack. Finally, we’ll explore new language features for both improving approachability of concurrency, and achieving peak performance when you need it.