在UIButton中添加“呼吸”动画会使其在Swift 4中无法点击

时间:2019-01-11 18:41:50

标签: swift uibutton uiviewanimation

在向其添加“呼吸”动画之前,我的按钮运行良好。现在,“呼吸”动画看起来很棒,但是我无法单击该按钮。有什么建议吗?

override func viewDidLoad() {
    super.viewDidLoad()

    UIView.animate(withDuration: 1.0,
     delay: 0,
     options: [.autoreverse, .repeat],
     animations: {
     self.playButton.transform = CGAffineTransform(scaleX: 1.175, y: 1.175)
     },
     completion: nil

     )

}

@IBAction func playClicked(_ sender: UIButton) {

    if playButton.currentImage == UIImage(named: "play_button") {

        // the following animation should occur upon button-click and is not related to the "breathing" animation
        UIView.animate(withDuration: 0.8, animations: {
            self.chooseLabel.alpha = 1
            self.spanishButton.alpha = 1
            self.italianButton.alpha = 1
            self.frenchButton.alpha = 1
            self.germanButton.alpha = 1
            self.playButton.alpha = 0
            self.globeImage.alpha = 0



            self.spanishButton.center = self.spanishButtonCenter
            self.italianButton.center = self.italianButtonCenter
            self.frenchButton.center = self.frenchButtonCenter
            self.germanButton.center = self.germanButtonCenter


        })
    }
}

0 个答案:

没有答案