【问题标题】:Change the background of the buttons "+", "-", "/", "*" when the button is pressed (clear and equal). (IOS)按下按钮时更改按钮“+”、“-”、“/”、“*”的背景(清晰且相等)。 (IOS)
【发布时间】:2017-08-05 19:49:44
【问题描述】:

我怎样才能使当我按下按钮(清除和相等)时,背景“+”、“-”、“/”、“*”变为灰色,就像按下之前一样。

 @IBAction func AnAnimate(_ sender: UIButton) {

    if sender.currentBackgroundImage == #imageLiteral(resourceName: "image_off") {
        sender.setBackgroundImage(#imageLiteral(resourceName: "Image_on"), for: .normal)
    } else {
        sender.setBackgroundImage(#imageLiteral(resourceName: "image_off"), for: .normal)
    }
    if (previousButton !== sender) {
        previousButton.setBackgroundImage(#imageLiteral(resourceName: "image_off"), for: .normal)

        previousButton = sender
    }
}

【问题讨论】:

    标签: ios swift3 xcode8 calculator


    【解决方案1】:

    假设您拥有buttonoutlet,那么当按下button 时,然后像这样更改所有buttonbackground 颜色。

    button1.backgroundColor = UIColor.gray
    button2.backgroundColor = UIColor.gray
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-06
      • 1970-01-01
      • 1970-01-01
      • 2014-10-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多