Instance Property

text

The text displayed by the text field.

Declaration

var text: String? { get set }

Discussion

This string is @"" by default.

Assigning a new value to this property also replaces the value of the attributedText property with the same text, albeit without any inherent style attributes. Instead the text view styles the new string using the font, textColor, and other style-related properties of the class.

See Also

Accessing the Text Attributes

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 textColor: UIColor?

The color 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.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software