Pete
Pete

Reputation: 613

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?

Upvotes: 3

Views: 7215

Answers (1)

lostInTransit
lostInTransit

Reputation: 70997

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

Upvotes: 7

Related Questions