iOS

Masonry动画更新约束

2017-11-23  本文已影响101人  ZhangYanSong

[self.view addSubview:siftView];

// siftView中含有子view, 此时在屏幕外

[siftView mas_makeConstraints:^(MASConstraintMaker *make) {

make.top.mas_equalTo(weakSelf.view.mas_top);

make.left.mas_equalTo(weakSelf.view.mas_left);

make.bottom.mas_equalTo(weakSelf.view.mas_bottom);

make.right.mas_equalTo(weakSelf.view.mas_right);

}];

// 动画开始前强制刷新

[siftView layoutIfNeeded];

// 更新约束

[siftView.siftView mas_updateConstraints:^(MASConstraintMaker *make) {

make.right.mas_equalTo(siftView.mas_right);

}];

// 在UIView的动画中调用强制刷新产生动画效果

[UIView animateWithDuration:0.2 animations:^{

[siftView layoutIfNeeded];

}];

上一篇下一篇

猜你喜欢

热点阅读