【发布时间】:2020-11-29 13:46:27
【问题描述】:
I do my swift project using code only no storyboards, so no storyboard solutions please I have an agree to terms button and when selected the checkmark is covered in the tint color I am trying to prevent the tint color highlighting the image when selected我不确定为什么会发生这种情况是按钮代码
let agreeToTermsAndConditions : UIButton = {
let button = UIButton(type: .system)
button.tintColor = .gray
button.backgroundColor = .white
button.adjustsImageWhenHighlighted = false
button.setImage(UIImage(named:"unchecked" )!, for: .normal)
button.setImage(UIImage(named:"agreechecked" )!, for: .selected)
button.addTarget(self, action: #selector(userAgreedToTerms), for: .touchUpInside)
return button
}()
代码使用 swift 4 和 iOS 12 部署在 xcode 10.2.1 上运行
【问题讨论】: