<!--
{
  "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/UITraitCollection/init(traitsFrom:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UITraitCollection(cm)traitCollectionWithTraitsFromCollections:"
  },
  "title" : "init(traitsFrom:)"
}
-->

# init(traitsFrom:)

Creates a trait collection that consists of traits merged from a specified array of trait collections.

```
init(traitsFrom traitCollections: [UITraitCollection])
```

## Parameters

`traitCollections`

An array of [`UITraitCollection`](/documentation/UIKit/UITraitCollection) objects.

## Return Value

A new trait collection consisting of traits merged from a specified `traitCollections` array.

## Discussion

This method takes an array of one or more trait collections and merges them to create a new trait collection. If the array contains more than one element, the highest-indexed element that contains a given trait is used for that trait. For example, the following code snippet creates a trait collection with a *compact* horizontal size class, because the second element in the array overrides the first for that trait:

```objc
UITraitCollection *newHorizontalSizeClass1 = [UITraitCollection traitCollectionWithHorizontalSizeClass: UIUserInterfaceSizeClassRegular];
UITraitCollection *newHorizontalSizeClass2 = [UITraitCollection traitCollectionWithHorizontalSizeClass: UIUserInterfaceSizeClassCompact];
NSArray *traitArray = [NSArray arrayWithObjects: newHorizontalSizeClass1, newHorizontalSizeClass2, nil];
UITraitCollection *combinedTraits = [UITraitCollection traitCollectionWithTraitsFromCollections: traitArray];
```

---

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)