How to make UILabel wordwrap

前端 未结 2 1700
灰色年华
灰色年华 2021-01-04 04:24

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

2条回答
  •  太阳男子
    2021-01-04 04:27

    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

提交回复
热议问题