---
title: "setAttributedText(_:)"
framework: watchkit
role: symbol
role_heading: Instance Method
path: "watchkit/wkinterfacelabel/setattributedtext(_:)"
---

# setAttributedText(_:)

Sets the label text to the specified attributed string.

## Declaration

```swift
func setAttributedText(_ attributedText: NSAttributedString?)
```

## Parameters

- `attributedText`: The formatted text string to be displayed in the label. Specifying nil clears the current text from the label.

## Mentioned in

Connecting Your User Interface to Your Code

## Discussion

Discussion This method changes the label text to the new value, replacing the old text if any. Any font and style attributes applied to the string take precedence over default values. If you do not explicitly specify font or styling information, the default values are used instead. For example, if you do not specify a text color explicitly, the default text color is used. Attributed strings may not contain any NSTextAttachment objects as part of their content.

## See Also

### Setting the Label Text

- [setText(_:)](watchkit/wkinterfacelabel/settext(_:).md)
- [setTextColor(_:)](watchkit/wkinterfacelabel/settextcolor(_:).md)
