Fade In Fade Out Animation

后端 未结 13 1260
生来不讨喜
生来不讨喜 2021-01-30 01:45

Here is some code I struggle with for a while.

If you start the fade in animation, the label text fades in. If I start the fade out animation the the label text fades ou

13条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-30 02:04

    Swift 4 If you need just one pulse when clicking the button, use that:

    @IBAction func didPressButton(_ sender: UIButton) {
            self.someView.alpha = 0
            UIView.animate(withDuration: 0.4,
                           delay: 0,
                           options: [.curveEaseInOut, .autoreverse],
                           animations: {
                            self.someView.alpha = 1
            },
                           completion: { _ in
                            self.someView.alpha = 0
            })
        }
    

提交回复
热议问题