---
title: Automatic trait tracking
framework: uikit
role: collectionGroup
role_heading: API Collection
path: uikit/automatic-trait-tracking
---

# Automatic trait tracking

Reduce the need to manually register for trait changes when you use traits within a method or closure that supports automatic trait tracking.

## Overview

Overview Automatic trait tracking is a UIKit feature that eliminates the need to manually register for trait changes when you use traits in a supported method or closure. This feature reduces the amount of code you need to write and maintain, improves performance, and encourages the best practice of using traits within the scope of the supported APIs. For more information, see Adapting your app when traits change. Some properties aren’t appropriate to change during layoutSubviews(), for example, properties where setting the value has a side-effect of invalidating the view’s layout. Update these properties in a view’s updateProperties() method, or a view controller’s updateProperties() method. These methods support automatic trait tracking, and automatic observation tracking on objects that use the Observable() macro. Notify an object of other updates to its properties by calling setNeedsUpdateProperties() on your view, or setNeedsUpdateProperties() on your view controller. Force an object to immediately update its properties by calling updatePropertiesIfNeeded() on your view, or updatePropertiesIfNeeded() on your view controller. For more information on automatically observing property updates, see Updating views automatically with observation tracking. important: Avoid causing excessive updates by avoiding changes in layoutSubviews() that update properties the object tracks in updateProperties(), or that invalidate the view’s layout. A complete list of APIs that support automatic trait tracking appears below.

## Topics

### Views

- [updateProperties()](uikit/uiview/updateproperties().md)
- [setNeedsUpdateProperties()](uikit/uiview/setneedsupdateproperties().md)
- [updatePropertiesIfNeeded()](uikit/uiview/updatepropertiesifneeded().md)
- [layoutSubviews()](uikit/uiview/layoutsubviews().md)
- [updateConstraints()](uikit/uiview/updateconstraints().md)
- [draw(_:)](uikit/uiview/draw(_:).md)
- [UIView.Invalidations.Properties](uikit/uiview/invalidations/properties.md)

### View controllers

- [updateProperties()](uikit/uiviewcontroller/updateproperties().md)
- [setNeedsUpdateProperties()](uikit/uiviewcontroller/setneedsupdateproperties().md)
- [updatePropertiesIfNeeded()](uikit/uiviewcontroller/updatepropertiesifneeded().md)
- [viewWillLayoutSubviews()](uikit/uiviewcontroller/viewwilllayoutsubviews().md)
- [viewDidLayoutSubviews()](uikit/uiviewcontroller/viewdidlayoutsubviews().md)
- [updateViewConstraints()](uikit/uiviewcontroller/updateviewconstraints().md)
- [updateContentUnavailableConfiguration(using:)](uikit/uiviewcontroller/updatecontentunavailableconfiguration(using:).md)

### Presentation controllers

- [containerViewWillLayoutSubviews()](uikit/uipresentationcontroller/containerviewwilllayoutsubviews().md)
- [containerViewDidLayoutSubviews()](uikit/uipresentationcontroller/containerviewdidlayoutsubviews().md)

### Buttons

- [updateConfiguration()](uikit/uibutton/updateconfiguration().md)
- [configurationUpdateHandler](uikit/uibutton/configurationupdatehandler-swift.property.md)

### Collection view cells

- [updateConfiguration(using:)](uikit/uicollectionviewcell/updateconfiguration(using:).md)
- [configurationUpdateHandler](uikit/uicollectionviewcell/configurationupdatehandler-7rqbu.md)

### Table view cells

- [updateConfiguration(using:)](uikit/uitableviewcell/updateconfiguration(using:).md)
- [configurationUpdateHandler](uikit/uitableviewcell/configurationupdatehandler-974.md)

### Table view headers and footers

- [updateConfiguration(using:)](uikit/uitableviewheaderfooterview/updateconfiguration(using:).md)
- [configurationUpdateHandler](uikit/uitableviewheaderfooterview/configurationupdatehandler-49slo.md)

### Collection view compositional layouts

- [UICollectionViewCompositionalLayoutSectionProvider](uikit/uicollectionviewcompositionallayoutsectionprovider.md)

## See Also

### Adaptivity

- [UITraitCollection](uikit/uitraitcollection.md)
- [UITraitEnvironment](uikit/uitraitenvironment.md)
- [UIAdaptivePresentationControllerDelegate](uikit/uiadaptivepresentationcontrollerdelegate.md)
- [UIContentContainer](uikit/uicontentcontainer.md)
