How do I animate constraint changes?

后端 未结 12 1814
野的像风
野的像风 2020-11-21 23:22

I\'m updating an old app with an AdBannerView and when there is no ad, it slides off screen. When there is an ad it slides on the screen. Basic stuff.

O

12条回答
  •  萌比男神i
    2020-11-21 23:57

    I was trying to animate Constraints and was not really easy to found a good explanation.

    What other answers are saying is totally true: you need to call [self.view layoutIfNeeded]; inside animateWithDuration: animations:. However, the other important point is to have pointers for every NSLayoutConstraint you want to animate.

    I created an example in GitHub.

提交回复
热议问题