【发布时间】:2021-03-18 15:57:30
【问题描述】:
我有一个使用系统图标作为图像的 UIButton,此时我正在使用以下设置色调颜色
buttonLogin?.tintColor = Globals().buttonFontColor
现在,当我按下按钮时,突出显示的状态会将色调颜色更改为深灰色。我想改变它,这样当我按下按钮时,颜色可以由我设置。我尝试过将按钮子类化,但没有成功。
import UIKit
class CustomButton: UIButton {
override open var isHighlighted: Bool {
didSet {
tintColor = isHighlighted ? UIColor.white : UIColor.green
}
}
/*
// Only override draw() if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func draw(_ rect: CGRect) {
// Drawing code
}
*/
}
谁能给我指出正确的方向谢谢。
【问题讨论】: