AutoLayout, Constraints and Animation

后端 未结 3 398
被撕碎了的回忆
被撕碎了的回忆 2021-01-03 04:31

Let\'s assume that I have this UIView:

\"enter

with these relativ

3条回答
  •  隐瞒了意图╮
    2021-01-03 05:06

    For animation you need to change constant of the left and top constraint instead of adding new constraint. As follows:

     self.mBtnTopConstraint.constant = yourval1;
        self.mBtmLeftConstraint.constant = yourval2;
        [yourbtn setNeedsUpdateConstraints];
    
        [UIView animateWithDuration:0.5 animations:^{
    
                [yourbtn layoutIfNeeded];
    
            } completion:^(BOOL isFinished){
            }];
    

    Hope this helps.

提交回复
热议问题