【问题标题】:How to adjust font size of text in a UIButton to fit the width programmatically in Swift?如何在 Swift 中以编程方式调整 UIButton 中文本的字体大小以适应宽度?
【发布时间】:2014-12-19 07:00:21
【问题描述】:

我正在尝试以编程方式在我的UIButton 中设置文本,但文本在按钮中显示时会缩写。有没有办法通过代码调整按钮中文本的字体大小以适应宽度?我检查了其他问题,但答案并没有解决我的问题。谢谢。

【问题讨论】:

  • 你试过这个button.titleLabel?.adjustsFontSizeToFitWidth = true

标签: ios swift uibutton resize xcode6


【解决方案1】:

为按钮对象添加这一行:

button.titleLabel?.adjustsFontSizeToFitWidth = true

【讨论】:

    【解决方案2】:
    猜你喜欢
    • 2015-12-10
    • 2017-07-24
    • 1970-01-01
    • 1970-01-01
    • 2015-04-28
    • 1970-01-01
    • 1970-01-01
    • 2018-10-16
    • 2018-11-10
    相关资源
    最近更新 更多