How to add line break for UILabel?

后端 未结 21 2131
失恋的感觉
失恋的感觉 2020-11-29 14:53

Let see that I have a string look like this:

NSString *longStr = @\"AAAAA\\nBBBBB\\nCCCCC\";  

How do I make it so that the UILabel disp

21条回答
  •  执念已碎
    2020-11-29 15:28

    If your using a UILabel you have to remember that the default setting is 1 line, so it does not matter how many breaks you add (\n or \r), you need to make sure it is set to more than one line so it could be allowed to append more lines.

    One alternative is to use UITextView which is really meant for multilines.

    You can easily achieve this in XCode attribute section of the UILabel, see screenshot:

    enter image description here

提交回复
热议问题