---
title: "setOverrideTraitCollection(_:forChild:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uiviewcontroller/setoverridetraitcollection(_:forchild:)"
---

# setOverrideTraitCollection(_:forChild:)

Changes the traits assigned to the specified child view controller.

## Declaration

```swift
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.

## Mentioned in

Choosing a specific interface style for your iOS app Creating a custom container view controller

## Discussion

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.

## See Also

### Deprecated methods

- [overrideTraitCollection(forChild:)](uikit/uiviewcontroller/overridetraitcollection(forchild:).md)
- [attemptRotationToDeviceOrientation()](uikit/uiviewcontroller/attemptrotationtodeviceorientation().md)
- [registerForPreviewing(with:sourceView:)](uikit/uiviewcontroller/registerforpreviewing(with:sourceview:).md)
- [unregisterForPreviewing(withContext:)](uikit/uiviewcontroller/unregisterforpreviewing(withcontext:).md)
- [canPerformUnwindSegueAction(_:from:withSender:)](uikit/uiviewcontroller/canperformunwindsegueaction(_:from:withsender:).md)
- [didRotate(from:)](uikit/uiviewcontroller/didrotate(from:).md)
- [dismissMoviePlayerViewControllerAnimated()](uikit/uiviewcontroller/dismissmovieplayerviewcontrolleranimated().md)
- [forUnwindSegueAction(_:from:withSender:)](uikit/uiviewcontroller/forunwindsegueaction(_:from:withsender:).md)
- [presentMoviePlayerViewControllerAnimated(_:)](uikit/uiviewcontroller/presentmovieplayerviewcontrolleranimated(_:).md)
- [rotatingFooterView()](uikit/uiviewcontroller/rotatingfooterview().md)
- [rotatingHeaderView()](uikit/uiviewcontroller/rotatingheaderview().md)
- [segueForUnwinding(to:from:identifier:)](uikit/uiviewcontroller/segueforunwinding(to:from:identifier:).md)
- [shouldAutomaticallyForwardRotationMethods()](uikit/uiviewcontroller/shouldautomaticallyforwardrotationmethods().md)
- [willAnimateRotation(to:duration:)](uikit/uiviewcontroller/willanimaterotation(to:duration:).md)
- [willRotate(to:duration:)](uikit/uiviewcontroller/willrotate(to:duration:).md)
