How to add line break for UILabel?

后端 未结 21 2169
失恋的感觉
失恋的感觉 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

    I have faced same problem, and here is, how i solved the problem. Hope this will be helpful for someone.

    // Swift 2

       lblMultiline.lineBreakMode = .ByWordWrapping // or use NSLineBreakMode.ByWordWrapping
       lblMultiline.numberOfLines = 0 
    

    // Objective-C

      lblMultiline.lineBreakMode = NSLineBreakByWordWrapping;
      lblMultiline.numberOfLines = 0;
    

    // C# (Xamarin.iOS)

      lblMultiline.LineBreakMode = UILineBreakMode.WordWrap;
      lblMultiline.Lines = 0;  
    

提交回复
热议问题