<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/PersonNameComponentsFormatter/annotatedString(from:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSPersonNameComponentsFormatter(im)annotatedStringFromPersonNameComponents:"
  },
  "title" : "annotatedString(from:)"
}
-->

# annotatedString(from:)

Returns an attributed string formatted for a given `NSPersonNameComponents` object, with attribute annotations for each component.

```
func annotatedString(from components: PersonNameComponents) -> NSAttributedString
```

## Parameters

`components`

A formatted string representation of the given name components.

## Return Value

An attributed string representation of the given name components. You can determine the person component corresponding to a particular range of the attributed string by querying the `NSPersonNameComponentKey` attribute, providing one of the `NSPersonNameComponent` constant values defined below as the attribute value.

## Discussion

Use this method to style individual components of a formatted name, such as a name in a label.

---

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)