第一步修改约束的值 , 第二步调用  [self.view layoutIfNeeded];

- (IBAction)buttonClick:(UIButton *)sender

{

    self.topViewC.constant += 70;

//    [self.topView setNeedsUpdateConstraints];

    // 调用此方法告诉self.view检测是否需要更新约束,若需要则更新,下面添加动画效果才起作用

//    [self.topView updateConstraintsIfNeeded];

    [UIView animateWithDuration:2.0 animations:^{

          [self.view layoutIfNeeded];

    }];

}

 

相关文章:

  • 2022-12-23
  • 2021-05-26
  • 2021-06-22
  • 2021-10-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-28
猜你喜欢
  • 2021-10-10
  • 2022-01-12
  • 2022-12-23
  • 2021-08-22
  • 2021-10-20
  • 2022-12-23
相关资源
相似解决方案