Auto change the font size to fit the button in swift

后端 未结 4 1702
青春惊慌失措
青春惊慌失措 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:18

    Adjust font size to fit width

    Swift

    self.button.titleLabel?.adjustsFontSizeToFitWidth = true
    

    Objective-C

    [self.button.titleLabel setAdjustsFontSizeToFitWidth:YES];
    

提交回复
热议问题