Blocks on Swift (animateWithDuration:animations:completion:)

前端 未结 7 1798
梦如初夏
梦如初夏 2020-12-02 12:08

I\'m having trouble making the blocks work on Swift. Here\'s an example that worked (without completion block):

UIView.animateWithDuration(0.07) {
    self.so         


        
相关标签:
7条回答
  • 2020-12-02 12:30

    SWIFT 3.x + 4.x

    I'd like to make an update and simplify the things.

    Example below is implemented in any view it is hiding slowly and when it is completely transparent; removes it self from parent view

    ok variable will always returns true with animation termination.

        alpha = 1
        UIView.animate(withDuration: 0.5, animations: {
            self.alpha = 0
        }) { (ok) in
            print("Ended \(ok)")
            self.removeFromSuperview()
        }
    
    0 讨论(0)
提交回复
热议问题