【问题标题】:Set a UIButton content alignment in iOS10在iOS10中设置一个UIButton内容对齐
【发布时间】:2017-06-11 23:48:54
【问题描述】:

好像不见了所以不能再做

How to alignment the text of button to the left?

我可以修改框架,但这也不起作用。

【问题讨论】:

    标签: ios uibutton


    【解决方案1】:

    使用此代码:

    yourButton.contentHorizontalAlignment = .left; //For horizontal alignment (.center, .left, .right, .fill)
    yourButton.contentVerticalAlignment = .center; //For vertical alignment (.bottom, .center, .fill, .top)
    

    您还可以在 IB 中设置控件对齐方式。

    【讨论】:

    • UIButton.h 没有相应的属性。你用的是哪个 iOS 版本?
    • 它是 UIControl 的属性,而不是 UIButton。此属性已在 iOS SDK 2.0 中添加
    【解决方案2】:

    您也可以在 IB 中执行此操作。进入 UIButton set Control 的属性检查器

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-02-26
      • 1970-01-01
      • 2019-12-11
      • 1970-01-01
      • 2021-09-05
      • 1970-01-01
      • 2011-02-15
      相关资源
      最近更新 更多