<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Contacts",
  "identifier" : "/documentation/Contacts/CNContactFormatter/attributedString(from:style:defaultAttributes:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Contacts"
    ],
    "preciseIdentifier" : "c:objc(cs)CNContactFormatter(cm)attributedStringFromContact:style:defaultAttributes:"
  },
  "title" : "attributedString(from:style:defaultAttributes:)"
}
-->

# attributedString(from:style:defaultAttributes:)

Formats the contact name as an attributed string.

```
class func attributedString(from contact: CNContact, style: CNContactFormatterStyle, defaultAttributes attributes: [AnyHashable : Any]? = nil) -> NSAttributedString?
```

## Parameters

`contact`

The contact whose name is to be formatted.

`style`

The formatting style to be used for the contact name.

`attributes`

The default attributes to use. For more information, see <doc://com.apple.documentation/documentation/Foundation/Formatter>.

## Return Value

The formatted contact name as an attributed string.

## Discussion

This method behaves similarly to [`string(from:style:)`](/documentation/Contacts/CNContactFormatter/string(from:style:)), except that it returns an attributed string. It includes the attribute key [`CNContactPropertyAttribute`](/documentation/Contacts/CNContactPropertyAttribute), whose attribute values are contact property keys, such as [`CNContactGivenNameKey`](/documentation/Contacts/CNContactGivenNameKey). This identifies the name components in the formatted contact name.

---

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)