<!--
{
  "availability" : [
    "iOS: 8.0.0 - 17.0.0",
    "iPadOS: 8.0.0 - 17.0.0",
    "macCatalyst: 13.1.0 - 17.0.0",
    "tvOS: -",
    "visionOS: 1.0.0 - 1.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIViewController/setOverrideTraitCollection(_:forChild:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIViewController(im)setOverrideTraitCollection:forChildViewController:"
  },
  "title" : "setOverrideTraitCollection(_:forChild:)"
}
-->

# setOverrideTraitCollection(_:forChild:)

Changes the traits assigned to the specified child view controller.

```
func setOverrideTraitCollection(_ collection: UITraitCollection?, forChild childViewController: UIViewController)
```

## Parameters

`collection`

The new traits to apply to the child view controller.

`childViewController`

The child view controller whose trait collection is to be changed.

## Discussion

Usually, traits are passed unmodified from the parent view controller to its child view controllers. When implementing a custom container view controller, you can use this method to change the traits of any embedded child view controllers to something more appropriate for your layout. Making such a change alters other view controller behaviors associated with that child. For example, modal presentations behave differently in a horizontally compact versus horizontally regular environment. You might also make such a change to force the same set of traits on the child view controller regardless of the actual trait environment.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)