【发布时间】:2018-03-21 09:45:15
【问题描述】:
当我使用该功能时,按钮无法正常工作。当我点击按钮时,按钮背景颜色会改变,当我们点击另一个按钮时,两个按钮的背景颜色都会改变。请告诉我如何解决这个错误。
@IBAction func btnNew(_ sender: Any)
{
if otlNewVisitor.isSelected == false
{
otlNewVisitor.isSelected == true
Button.buttonPressed(button: otlNewVisitor, boolResult: true, titleColor: UIColor.white, strImage: "icn-new-visitor-wht", bgColor: UIColor(red: 30/255, green: 104/255, blue: 140/255, alpha: 1), imgVW: imgNewVis)
//Entered SubmitDetails Screen
let submitVC = self.storyboard?.instantiateViewController(withIdentifier: "SubmitDetailsVC") as! SubmitDetailsVC
self.navigationController?.pushViewController(submitVC, animated: true)
}
else
{
otlNewVisitor.isSelected == false
//Button Colow did change
Button.buttonPressed(button: otlNewVisitor, boolResult: false, titleColor: UIColor(red: 30/255, green: 104/255, blue: 140/255, alpha: 1), strImage: "icn-new-visitor", bgColor: UIColor.white, imgVW: imgNewVis)
}
}
【问题讨论】:
-
显示
Button.buttonPressed的代码 -
另外,您没有在比较后使用
==设置状态(可能您收到警告)