Adjust font size of text to fit in UIButton

前端 未结 9 1011
予麋鹿
予麋鹿 2020-12-08 02:12

I want to make sure the button text fits into a UIButton, while the UIButton has a fixed size.

Of course I can access the titleLabel of the UIButton. In a label I w

9条回答
  •  孤城傲影
    2020-12-08 03:14

    You can also set a User Defined Runtime Attribute in Interface Builder for the button where

    titleLabel.adjustsFontSizeToFitWidth = true
    

提交回复
热议问题