gpt4 book ai didi

ios - 当选择 UIButton 时,文本标签上会出现一个白色框

转载 作者:行者123 更新时间:2023-11-30 11:37:18 26 4
gpt4 key购买 nike

我有一个按钮,当选择该按钮时,按钮的标题文本上方会出现一个白色框。我不希望出现这个白框。查看图片。 button state unselected button state selected

如果我删除 if 语句并拥有按钮,因此只能选择但不能取消选择,则在选择时,不会出现此白框。控制它的代码如下...

@IBAction func backButtonPressed(_ sender: Any) {
if let button = sender as? UIButton {
if button.isSelected {
createWorkoutButton.isEnabled = false
backButton.backgroundColor = #colorLiteral
backButtonPressed = false
backButton.isSelected = false
} else {
createWorkoutButton.isEnabled = true
backButton.backgroundColor = #colorLiteral
backButtonPressed = true
backButton.isSelected = true
}
}
}

最佳答案

刚找到解决方案。添加这行代码 -

 button.tintColor = .clear

现在 -

@IBAction func backButtonPressed(_ sender: Any) {
if let button = sender as? UIButton {
if button.isSelected {
createWorkoutButton.isEnabled = false
backButton.backgroundColor = #colorLiteral
backButtonPressed = false
backButton.isSelected = false
button.tintColor = .clear // Add this line of code
} else {
createWorkoutButton.isEnabled = true
backButton.backgroundColor = #colorLiteral
backButtonPressed = true
backButton.isSelected = true
button.tintColor = .clear
}
}
}

关于ios - 当选择 UIButton 时,文本标签上会出现一个白色框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49609747/

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