UITextView: text property
The text property is the full content of the text view.
Value
A string; line breaks are \n.
- Readable and writable.
- The default value is the empty string
''. With no content it is'', notnull. - Writing
nullorundefinedgives''. - After writing, the cursor is at the end of the content (measured).
inputfires when user input changes the content. Writingtextin code doesn't fireinput(measured). So after writingtext, update any UI that depends on the content yourself; writingtextin aninputcallback doesn't trigger the callback again.- Writing
textafterattributedTexthas been written removes the previous styles (measured).
Examples
js
const input = new UITextView();
input.text = 'Line 1\nLine 2';
console.log(input.text.length, input.hasText);Result: logs 13 true. The text view shows two lines of text.
Corresponding iOS API
UITextView.text.
See also
insertText(): change the content as if the user typed itinputevent