<!--
{
  "availability" : [
    "macOS: 10.12.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextField/init(labelWithAttributedString:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextField(cm)labelWithAttributedString:"
  },
  "title" : "init(labelWithAttributedString:)"
}
-->

# init(labelWithAttributedString:)

Creates a text field for use as a static label that displays styled text, doesn’t wrap, and doesn’t have selectable text.

```
convenience init(labelWithAttributedString attributedStringValue: NSAttributedString)
```

## Parameters

`attributedStringValue`

An attributed string to use as the content of the label.

## Return Value

A text field that displays the specified attributed string as a static label.

## Discussion

The text field determines its line-break mode by inspecting the paragraph style attributes in the attributed string.

> Note:
> When the text field has an attributed string value, the system ignores the ``doc://com.apple.appkit/documentation/AppKit/NSTextField/textColor``, ``doc://com.apple.appkit/documentation/AppKit/NSControl/font``, ``doc://com.apple.appkit/documentation/AppKit/NSControl/alignment``, ``doc://com.apple.appkit/documentation/AppKit/NSControl/lineBreakMode``, and `lineBreakStrategy` properties. Set the <doc://com.apple.documentation/documentation/Foundation/NSAttributedString/Key/foregroundColor>, <doc://com.apple.documentation/documentation/Foundation/NSAttributedString/Key/font>, ``doc://com.apple.appkit/documentation/AppKit/NSMutableParagraphStyle/alignment``, linebreakmode, and ``doc://com.apple.appkit/documentation/AppKit/NSParagraphStyle/lineBreakStrategy-swift.property`` properties in the attributed string instead.

---

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)