UIButton不会在每次点击时“闪烁”

时间:2019-01-10 13:44:59

标签: ios uibutton

我在UIButtons中有3个UIView,它们具有相同的文本颜色和相同的背景颜色。轻按三个按钮即可触发相应的事件。但是只有其中之一会响应触摸而“闪烁”。其他两个会发生什么?它们有时(但很少)具有“闪烁”行为,但是touch up inside event总是在点击时触发。

按钮已添加到storyboard中:

enter image description here

2 个答案:

答案 0 :(得分:0)

 func btnFlash_Clicked(sender: AnyObject) {
     if !flashing{
        callButton.alpha = 1.0
        UIView.animate(withDuration: 0.5, delay: 0.0, options: [.allowUserInteraction], animations: {() -> Void in
            callButton.alpha = 0.5
        }, completion: {(finished: Bool) -> Void in
        })

        flashing = true
     } else{
        flashing = false
        callButton.alpha = 0.5
        UIView.animate(withDuration: 0.5, delay: 0.0, options: [.allowUserInteraction], animations: {() -> Void in
            callButton.alpha = 1.0
        }, completion: {(finished: Bool) -> Void in
        })

答案 1 :(得分:0)

我将按钮类型设置为UIButtonTypeCustom以停止闪烁。