美文网首页
在 AutoLayout 和 Masonry 中使用[UIVie

在 AutoLayout 和 Masonry 中使用[UIVie

作者: 暗光的技术小站 | 来源:发表于2019-10-29 14:37 被阅读0次

问题描述:

一个UIImageView做动画时,未按设置的frame做动画。

原因:

由于用Masonry设置了约束,设置动画时,需要用updateConstraints重设约束

AutoLayout中例子如下所示:

[UIView animateWithDuration:2.0f delay:0  animations:^{

    // 修改 animationView 的约束

    animationView.widthConstraint.constant = 20.f;

    // 注意这里要调用 animationView 父视图的 layoutIfNeeded 方法,这里为superview

    [superview layoutIfNeeded];

} completion:^(BOOL finished) {

}];

相关文章

网友评论

      本文标题:在 AutoLayout 和 Masonry 中使用[UIVie

      本文链接:https://www.haomeiwen.com/subject/yszwvctx.html