删除所选UIButton中的突出显示

时间:2016-06-08 06:03:34

标签: ios swift uibutton uicontrol

普通的UIButton看起来应该是这样的(我知道按钮应该与其他文本有不同的颜色,但这是一种特殊情况):

enter image description here

我想使用UIButton的selected属性来确定它是否应该是粗体,并且我已经将.Selected控件状态设置为包含以下代码的粗体文本:

let boldedOption = [NSFontAttributeName: UIFont.boldSystemFontOfSize(15), NSForegroundColorAttributeName: UIColor.whiteColor()]
signInButton.setAttributedTitle(NSAttributedString(string: "SIGN IN", attributes: boldedOption), forState: .Selected)

但是,当我以编程方式将按钮的selected属性设置为true时,结果就是:

enter image description here

我最初希望实现的是,只要UIButton的selected属性为true,按钮就会出现粗体文本,但在这种情况下,边框会挡住,文本为当然也不是白人。

有没有办法根据具有selected属性的用户输入动态加粗UIButton的文本,或者我是否必须使用布尔值将另一个不太优雅的解决方案混合在一起?

1 个答案:

答案 0 :(得分:3)

将按钮类型更改为“自定义”而不是“系统”。这将照顾你的蓝色背景。

enter image description here