How can I make text in a UILabel shrink font size

后端 未结 4 617
慢半拍i
慢半拍i 2021-02-03 22:45

If a UILabel contains too much text, how can I setup my label so that it shrinks font-sizes?

Here is how I am setting up my UILabel:

     descriptionLabe         


        
4条回答
  •  梦如初夏
    2021-02-03 23:13

    If you want the number of lines to also increase if needed, use Steve N's solution, with the if statement as so:

    if(labelSize.height <= aLabel.frame.size.height)
    {
      aLabel.numberOfLines = labelSize.height / font.lineHeight;
    
      break;
    }
    

提交回复
热议问题