【问题标题】:Button text is cut and not centered按钮文本被剪切而不居中
【发布时间】:2017-04-02 20:35:08
【问题描述】:

我使用故事板创建了一个按钮,该按钮被分配了cornerRadius、borderWidth、textAlignment 和clipsToBounds 属性。通过代码,我分配了以下文本以适应按钮的宽度。但是执行的时候不是垂直居中的,也是可视化的。

añadirOtrosCursos.titleLabel?.minimumScaleFactor = 0.5
añadirOtrosCursos.titleLabel?.numberOfLines = 1              
añadirOtrosCursos.titleLabel?.adjustsFontSizeToFitWidth = true
añadirOtrosCursos.contentVerticalAlignment = .center

【问题讨论】:

    标签: swift button properties


    【解决方案1】:

    尝试单击 Main.storyboard 中的 UIButton,转到属性检查器,向下滚动到“控件”类别,并确保将垂直对齐设置为居中。 This is what you should see.

    【讨论】:

    • 是的,我都设置了中心
    【解决方案2】:

    这很简单,只需打开你的故事板,选择你的按钮并更改按钮属性,如下图所示。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-13
      • 1970-01-01
      • 1970-01-01
      • 2020-10-20
      • 1970-01-01
      • 2021-06-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多