How to make UILabel wordwrap

有些话、适合烂在心里 提交于 2019-12-30 05:54:28

问题


Is there anyway of making a UILabel wrap to the next line or do I have to use a UITextView?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/4626548/how-to-make-uilabel-wordwrap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!