在iOS10

时间:2017-06-11 23:48:55

标签: ios uibutton

似乎缺少所以我不能再做了

How to alignment the text of button to the left?

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

2 个答案:

答案 0 :(得分:1)

使用此代码:

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

您也可以在IB中设置控制对齐。

答案 1 :(得分:0)

您也可以在IB中执行此操作。进入UIButton设置控件

的属性检查器

enter image description here