我对UIButton
的文本左对齐有问题.我也试着把它改成.Right
,但它仍然保持在中心位置.我也try 了aButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 0)
而不是aButton.titleLabel?.textAlignment = .Left
,但这也没有改变任何事情.有没有其他方法可以通过编程更改UIButton
个标题的对齐方式?
allButtonViews = UIView(frame: CGRectMake(0, 44, 100, 100))
allButtonViews.backgroundColor = .redColor()
let campusButton = UIButton(type: UIButtonType.System) as UIButton
aButton.frame = CGRectMake(0, 0, 300, 70)
aButton.setTitle("A", forState: .Normal)
aButton.titleLabel?.textColor = .blueColor()
aButton.titleLabel?.textAlignment = .Left
aButton.backgroundColor = .whiteColor()
sortView.addSubview(aButton)
view.addSubview(allButtonViews)