UILabel height calculation

后端 未结 2 723
迷失自我
迷失自我 2021-01-15 15:53

I have UILabel that the text is dynamically change based on server data. Sometime the data is so long that make my UILabel become multiline. Is the

2条回答
  •  难免孤独
    2021-01-15 16:14

    You can use this :

    var labelHeight : CGFloat
    labelHeight = theLabel.boundingHeightForFixedWidth(theLabel.bounds.width)
    

    Hope it help :)

提交回复
热议问题