UIButton闪烁正在工作,但是按钮操作不工作

时间:2019-03-25 03:56:54

标签: ios swift uibutton

使用“ @IBOutlet var checkAvalibilityBtn:UIButton!”,创建一个闪烁的代码,并在viewdidLoad中调用

   `override func viewDidLoad() {
    super.viewDidLoad()

    self.checkAvalibilityBtn.alpha = 1.0
    UIView.animate(withDuration: 0.80, delay: 0.0, options: [.curveEaseIn, .repeat, .autoreverse, .allowUserInteraction], animations: {() -> Void in
        self.checkAvalibilityBtn.alpha = 0.0
    }, completion: {(finished: Bool) -> Void in
    })`

但是对接操作不起作用

@IBAction func checkBAvaBtnClick(_ sender: UIButton) { print("Success") }

1 个答案:

答案 0 :(得分:2)

view alpha 0不能从系统接收触摸事件,请参考旧的answer

override func viewDidLoad() {
    super.viewDidLoad()

    self.checkAvalibilityBtn.alpha = 0.0
    UIView.animate(withDuration: 0.80, delay: 0.0, options: [.curveEaseIn, .repeat, .autoreverse, .allowUserInteraction], animations: {() -> Void in
        self.checkAvalibilityBtn.alpha = 1.0
    }, completion: {(finished: Bool) -> Void in
    })