---
title: textColor
framework: uikit
role: symbol
role_heading: Instance Property
path: uikit/uitextfield/textcolor
---

# textColor

The color of the text.

## Declaration

```swift
var textColor: UIColor? { get set }
```

## Discussion

Discussion This property applies to the entire text string. The default value for this property is a black color. The value for the property can only be set to a non-nil value; setting this property to nil raises an exception. If you are using styled text, assigning a new value to this property causes the text color to be applied to the entire string in the attributedText property. If you want to apply the color to only a portion of the text, create a new attributed string with the desired style information and associate it with the text field.

## See Also

### Configuring the text attributes

- [text](uikit/uitextfield/text.md)
- [attributedText](uikit/uitextfield/attributedtext.md)
- [placeholder](uikit/uitextfield/placeholder.md)
- [attributedPlaceholder](uikit/uitextfield/attributedplaceholder.md)
- [defaultTextAttributes](uikit/uitextfield/defaulttextattributes.md)
- [font](uikit/uitextfield/font.md)
- [textAlignment](uikit/uitextfield/textalignment.md)
- [typingAttributes](uikit/uitextfield/typingattributes.md)
- [UITextField.BorderStyle](uikit/uitextfield/borderstyle-swift.enum.md)
