解释 UIView.updateProperties
Asked on 06/12/2025
1 search
UIView.updateProperties
is a new method introduced in UIKit to enhance the way views update their properties. It is designed to work alongside the existing layoutSubviews
method, providing a more efficient way to update properties without forcing a layout pass. This method is particularly useful for populating content, applying styling, or configuring behaviors.
The updateProperties
method runs just before layoutSubviews
but is independent of it, allowing you to invalidate properties without triggering a layout pass and vice versa. This separation helps avoid unnecessary work and improves performance by allowing finer-grained updates. It automatically tracks any observable you read, and you can manually trigger it by calling setNeedsUpdateProperties
.
For example, if you have an observable model object, changes to this object will automatically trigger updateProperties
, allowing the view to update accordingly without needing to rewrite code for unrelated events like resizing.
For more details, you can refer to the session What’s new in UIKit (12:30).

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.

Optimize SwiftUI performance with Instruments
Discover the new SwiftUI instrument. We’ll cover how SwiftUI updates views, how changes in your app’s data affect those updates, and how the new instrument helps you visualize those causes and effects. To get the most out of this session, we recommend being familiar with writing apps in SwiftUI.

Enhance your UI animations and transitions
Explore how to adopt the zoom transition in navigation and presentations to increase the sense of continuity in your app, and learn how to animate UIKit views with SwiftUI animations to make it easier to build animations that feel continuous.