Remove animation in swift

前端 未结 1 656
余生分开走
余生分开走 2021-02-05 13:35

I have a text field where user should enter info. And a label which points user to text field (like a hint).

I want to stop animation and remove hint label once user pr

1条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-05 13:53

    //Just remove the animation from the label. It will Work
    
     func remove()
    
    {
        self.hintLabel.layer.removeAllAnimations()
        self.view.layer.removeAllAnimations()
        self.view.layoutIfNeeded()
    
    }
    

    Update:

    If you want to go nuclear, you could do this, as well:

    func nukeAllAnimations() {
        self.view.subviews.forEach({$0.layer.removeAllAnimations()})
        self.view.layer.removeAllAnimations()
        self.view.layoutIfNeeded()
    }
    

    0 讨论(0)
提交回复
热议问题