您的位置:首页 > 编程语言

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

2015-09-25 16:33 651 查看
例:将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) {
}];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: