---
title: "setAttributedTitle(_:for:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uibutton/setattributedtitle(_:for:)"
---

# setAttributedTitle(_:for:)

Sets the styled title to use for the specified state.

## Declaration

```swift
func setAttributedTitle(_ title: NSAttributedString?, for state: UIControl.State)
```

## Parameters

- `title`: The styled text string so use for the title.
- `state`: The state that uses the specified title. The possible values are described in doc://com.apple.uikit/documentation/UIKit/UIControl/State-swift.struct.

## Discussion

Discussion Use this method to set the title of the button, including any relevant formatting information. If you set both a title and an attributed title for the button, the button prefers the use of the attributed title. At a minimum, you should set the value for the normal state. If a title is not specified for a state, the default behavior is to use the title associated with the normal state. If the value for normal is not set, then the property defaults to a system value.

## See Also

### Managing the title

- [titleLabel](uikit/uibutton/titlelabel.md)
- [title(for:)](uikit/uibutton/title(for:).md)
- [setTitle(_:for:)](uikit/uibutton/settitle(_:for:).md)
- [attributedTitle(for:)](uikit/uibutton/attributedtitle(for:).md)
- [titleColor(for:)](uikit/uibutton/titlecolor(for:).md)
- [setTitleColor(_:for:)](uikit/uibutton/settitlecolor(_:for:).md)
- [titleShadowColor(for:)](uikit/uibutton/titleshadowcolor(for:).md)
- [setTitleShadowColor(_:for:)](uikit/uibutton/settitleshadowcolor(_:for:).md)
