constraints 狀態下移動view ,畫面翻轉後回到原位


  • storyboard 物件的constraints可以拉到.m檔案裡面做操作
  • 原本改變view的方式改成修改constant

加入動畫


//修改限制
cX.constant += 100;
cH.constant += 20;
//更新限制
[self.view setNeedsUpdateConstraints];

[UIView animateWithDuration:0.25 animations:^{
    [self.view layoutIfNeed];
}]


留言