Instance Property

textColor

The color of the text.

Declaration

var textColor: UIColor? { get set }

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

Accessing the Text Attributes

var text: String?

The text displayed by the text field.

var attributedText: NSAttributedString?

The styled text displayed by the text field.

var placeholder: String?

The string that is displayed when there is no other text in the text field.

var attributedPlaceholder: NSAttributedString?

The styled string that is displayed when there is no other text in the text field.

var defaultTextAttributes: [NSAttributedString.Key : Any]

The default attributes to apply to the text.

var font: UIFont?

The font of the text.

var textAlignment: NSTextAlignment

The technique to use for aligning the text.

var typingAttributes: [NSAttributedString.Key : Any]?

The attributes to apply to new text being entered by the user.

enum UITextField.BorderStyle

The type of border drawn around the text field.