How do I animate constraint changes?

后端 未结 12 1668
野的像风
野的像风 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
    慢半拍i (楼主)
    2020-11-21 23:59

    In the context of constraint animation, I would like to mention a specific situation where I animated a constraint immediately within a keyboard_opened notification.

    Constraint defined a top space from a textfield to top of the container. Upon keyboard opening, I just divide the constant by 2.

    I was unable to achieve a conistent smooth constraint animation directly within the keyboard notification. About half the times view would just jump to its new position - without animating.

    It occured to me there might be some additional layouting happening as result of keyboard opening. Adding a simple dispatch_after block with a 10ms delay made the animation run every time - no jumping.

提交回复
热议问题