按钮上的两种颜色(快速)

时间:2020-09-09 18:34:03

标签: ios swift

未选择的按钮如下所示: enter image description here

所选按钮如下所示:enter image description here

为什么会有两种蓝色阴影?如何摆脱内部较浅的蓝色阴影?我希望整个按钮为单一纯色。

我看过.backgroundColor,以为可能是.foregroundColor,但是我找不到正在做的事情...

这是我正在使用的:

func buttonArrayUpdated(buttonSelected: UIButton) {
    for b in buttonsArray {
        if b == buttonSelected {
            selectedButton = b
            b.isSelected = true
            // default colors for state
            b.backgroundColor = .blue
            b.setTitleColor(.white, for: .selected)
        }
        else {
            b.isSelected = false
            // default colors for state
            b.backgroundColor = .white
            b.setTitleColor(.blue, for: .normal)
        }
    }
}

1 个答案:

答案 0 :(得分:1)

您可以执行以下操作以删除该背景色:

 button.tintColor = .clear