How do I animate constraint changes?

后端 未结 12 1832
野的像风
野的像风 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条回答
  •  暖寄归人
    2020-11-21 23:58

    // Step 1, update your constraint
    self.myOutletToConstraint.constant = 50; // New height (for example)
    
    // Step 2, trigger animation
    [UIView animateWithDuration:2.0 animations:^{
    
        // Step 3, call layoutIfNeeded on your animated view's parent
        [self.view layoutIfNeeded];
    }];
    

提交回复
热议问题