美文网首页
笔记—约束变化动画处理 .constant动画

笔记—约束变化动画处理 .constant动画

作者: 离离乱惑 | 来源:发表于2017-05-23 10:52 被阅读19次

项目中使用Storyboard布局,要做一个高度改变的动画效果,直接使用uiview动画,

[UIView animateWithDuration:0.25 animations:^{
        self.heigthForCollection.constant = 20;
    }];

约束直接跳到20,没有一个动画的过程,UIView动画对Constraint不起作用。

解决方法

        self.heigthForCollection.constant = 20;
        [UIView animateWithDuration:0.25 animations:^{
            [self.view layoutIfNeeded];
        }];

当然也可以不使用约束,直接通过动画改变frame.

相关文章

网友评论

      本文标题:笔记—约束变化动画处理 .constant动画

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