Auto change the font size to fit the button in swift

后端 未结 4 1676
青春惊慌失措
青春惊慌失措 2021-02-20 07:47

I have tried this but it didn\'t work, the text is out of the button boundaries.

button.titleLabel!.adjustsFontSizeToFitWidth = true
button.titleLabel!.numberOfL         


        
4条回答
  •  失恋的感觉
    2021-02-20 08:31

    UIButton font scaling can be very fickle, I've had problems with it in the past. What I did was make the number of lines equal to 1, which worked for me.

提交回复
热议问题