<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UITabBarItem/setBadgeTextAttributes(_:for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UITabBarItem(im)setBadgeTextAttributes:forState:"
  },
  "title" : "setBadgeTextAttributes(_:for:)"
}
-->

# setBadgeTextAttributes(_:for:)

Registers text attributes that the badge uses for the specified state.

```
func setBadgeTextAttributes(_ textAttributes: [NSAttributedString.Key : Any]?, for state: UIControl.State)
```

## Parameters

`textAttributes`

A dictionary of text attributes. For a list of possible attributes, see <doc://com.apple.documentation/documentation/Foundation/NSAttributedString/Key>.

`state`

The item’s state. For possible values, see [`UIControl.State`](/documentation/UIKit/UIControl/State-swift.struct).

## Discussion

The [`setTitleTextAttributes(_:for:)`](/documentation/UIKit/UIBarItem/setTitleTextAttributes(_:for:)) method allows you to customize the appearance of the item’s title. Use this method to apply similar customizations to the badge’s value to achieve a consistent appearance.

---

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)