0

使用下面的代码,我似乎无法运行反向动画。

   // UIViewPropertyAnimator
     let customBlur = BlurView.init(effect: UIBlurEffect.init(style:UIBlurEffect.Style.systemThickMaterialDark), intensity: 0)
    var onState = false
    @IBAction func button1(_ sender: UIButton) {

        if onState == false{
            print("add")
            self.customBlur.animator?.startAnimation()
        }else{
            print("remove")
            self.customBlur.animator?.isReversed = true
            self.customBlur.animator?.startAnimation()

        }   
        onState = !onState //toggle
    }

第一次按下按钮时动画运行,但单击第二次时间print("remove")线时会打印但动画不会反转。我该如何解决?

4

0 回答 0