开发者

How to make UILabel wordwrap

开发者 https://www.devze.com 2023-02-03 06:01 出处:网络
Is there anyway of making a UILabel wrap to开发者_JAVA技巧 the next line or do I have to use a UITextView?You would need to set the numberOfLines property to 0 and explicitly specify its dimensions, e

Is there anyway of making a UILabel wrap to开发者_JAVA技巧 the next line or do I have to use a UITextView?


You would need to set the numberOfLines property to 0 and explicitly specify its dimensions, either in IB or programmatically. However, if you have a lot of text to display, I would recommend using a UITextView.


What you want is to adjust your label according to the content's size.

In iOS 6, AutoLayout will work a charm, you should set the label to have numberOfLines = 0

In a non AutoLayout scenario, you will also want to make sure the frame of your UILabel is adjusted to show the content that's on the next line.

Please check out this answer and sample code for that: https://stackoverflow.com/a/8796896/662605

0

精彩评论

暂无评论...
验证码 换一张
取 消