首页 > 其他 > 详细

使用Autolayout和约束后,用代码改变view的位置,并实现动画效果

时间:2015-09-25 17:53:35      阅读:238      评论:0      收藏:0      [点我收藏+]

例:将view上移

    //这种情况即使设置动画,还是没有动画效果
    [UIView animateWithDuration:0.3
                     animations:^{
                         
                        topLayout.constant = 0.0f;//需要移动到Y位置就设为Y
                         
                     } completion:^(BOOL finished) {
                     }];
    
    //解决方法
    [self.view layoutIfNeeded];
    [UIView animateWithDuration:0.3
                     animations:^{
                         
                         topLayout.constant = 0.0f;//需要移动到Y位置就设为Y
                         [self.view layoutIfNeeded];

                     } completion:^(BOOL finished) {
                     }];

 

使用Autolayout和约束后,用代码改变view的位置,并实现动画效果

原文:http://www.cnblogs.com/rgshio/p/4838662.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!