---
title: "makeAttributedString(font:foregroundColor:textAlignment:)"
framework: tvmlkit
role: symbol
role_heading: Instance Method
path: "tvmlkit/tvtextelement/makeattributedstring(font:foregroundcolor:textalignment:)"
---

# makeAttributedString(font:foregroundColor:textAlignment:)

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

## Declaration

```swift
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

Return Value An NSAttributedString object with the applied attributes.

## Discussion

Discussion Supply a font to this method to get the NSAttributedString representation of the text contained within an element. Use the foregroundColor and alignment parameters to override the value specified in the text element.

## See Also

### Creating Attributed Strings

- [makeAttributedString(font:)](tvmlkit/tvtextelement/makeattributedstring(font:).md)
