gpt4 book ai didi

ios - 删除所选 UIButton 中的突出显示

转载 作者:可可西里 更新时间:2023-11-01 00:59:18 26 4
gpt4 key购买 nike

一个普通的 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 的文本,还是我必须用 bool 值组合另一个不太优雅的解决方案?

最佳答案

将按钮类型更改为自定义而不是系统。这将处理您的蓝色背景。

enter image description here

关于ios - 删除所选 UIButton 中的突出显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37694404/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com