<!--
{
  "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/containsTraits(in:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UITraitCollection(im)containsTraitsInCollection:"
  },
  "title" : "containsTraits(in:)"
}
-->

# containsTraits(in:)

Queries whether a trait collection contains all of another trait collection’s values.

```
func containsTraits(in trait: UITraitCollection?) -> Bool
```

## Parameters

`trait`

A trait collection that you want to compare to the current trait collection.

## Return Value

This method returns <doc://com.apple.documentation/documentation/Swift/true> if the receiver contains all of the trait values in the trait collection passed in the `trait` parameter, and returns <doc://com.apple.documentation/documentation/Swift/false> otherwise.

## Discussion

Use this method to compare two standalone trait collections, or to compare the iOS interface environment’s trait collection to a standalone trait collection.

---

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)