Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Newline and / or Carriage Return in Swift String

I am attempting to add a Newline or Carriage return in a UITextView.

    var text = UITextField()
    text.text = "This is a text \r\n This is a text"

The result shows the entire text on one line:

This is a text This is a text

Is it not possible to do a Newline or CR in a UITextView? Or what am I missing here?

like image 627
Pete Avatar asked Nov 27 '25 02:11

Pete


1 Answers

UITextField is generally single-line and does not support multiline text. Use a UITextView instead

like image 105
lostInTransit Avatar answered Nov 29 '25 20:11

lostInTransit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!