<!--
{
  "availability" : [
    "tvOS: 9.0.0 - 18.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "TVMLKit",
  "identifier" : "/documentation/TVMLKit/TVTextElement/makeAttributedString(font:foregroundColor:textAlignment:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "TVMLKit"
    ],
    "preciseIdentifier" : "c:objc(cs)TVTextElement(im)attributedStringWithFont:foregroundColor:textAlignment:"
  },
  "title" : "makeAttributedString(font:foregroundColor:textAlignment:)"
}
-->

# makeAttributedString(font:foregroundColor:textAlignment:)

Convenience method for configuring an attributed string given the specified attributes.

```
func makeAttributedString(font: UIFont, foregroundColor: UIColor?, textAlignment alignment: NSTextAlignment) -> NSAttributedString
```

## Parameters

`font`

The font used for the attributed string. This can be any available font on the device.

`foregroundColor`

The foreground color for the element.

`alignment`

The alignment for the text contained within the element.

## Return Value

An <doc://com.apple.documentation/documentation/Foundation/NSAttributedString> object with the applied attributes.

## Discussion

Supply a font to this method to get the <doc://com.apple.documentation/documentation/Foundation/NSAttributedString> representation of the text contained within an element. Use the `foregroundColor` and `alignment` parameters to override the value specified in the text element.

---

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)