iOS開發筆記-Autolayout自動佈局與UIView動畫
阿新 • • 發佈:2019-02-15
使用了Autolaout的檢視的動畫
方法一:簡單的說就是先找到想要變化的NSLayoutConstraint
然後改變constant值
NSLayoutConstraint * _bottomCelectVLocRight;
_bottomCelectVLocRight.constant = 0;
[UIView animateWithDuration:.5 animations:^{
[self.view layoutIfNeeded];
}];
方法二:把你想要做動畫的view的translatesAutoresizingMaskIntoconstraints為yes[UIView animateWithDuration:.5 animations:^{ _bottomCoolectView.translatesAutoresizingMaskIntoConstraints = YES; _bottomCoolectView.frame = CGRectMake(CGRectGetMinX(_bottomCoolectView.frame)-bottomCoolectViewWidth, CGRectGetMinY(_bottomCoolectView.frame), CGRectGetWidth(_bottomCoolectView.frame), CGRectGetHeight(_bottomCoolectView.frame)); }];