动画/下自动布局的使用移动视图 [英] Animating/Moving views under usage of Autolayout

查看:93
本文介绍了动画/下自动布局的使用移动视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从一个现在的位置移动视图到另一个,我可以用它实现

I want to move a view from one postion to another, I can implement it using

self.view.center = CGPointMake(100, 200);

但是,如果项目使用自动布局,那么该视图会回到原来的位置后运行:

however, if the project is using Autolayout, then the view will be back to original position after running:

[self.view.superview setNeedsLayout];

那么如何实际移动,以便新的位置?

then how to actually move a view to new position?

推荐答案

如果您正在使用的autoLayout您必须更改限制。该建议的方法是使的出口,限制你的视图控制器,那么你改变约束的常数。如果你有时间我肯定会推荐去这里和看的实例自动布局或最佳实践为掌握自动布局。他们帮助了我很多。我想带走一点,使用的autoLayout,你不再觉得在帧的条款。因此,设置中心只是不带自动布置工作。这是所有关于看法是如何相互关联的。

You must change the constraints if you are using autoLayout. The way that is suggested is to make an outlet in your view controller of the constraint, then you change the constant of the constraint. If you have the time i would definitely recommend going here and watching "Auto Layout by Example" or "Best Practices for Mastering Auto Layout". They helped me out a lot. I guess the point to take away is that with autoLayout, you no longer think in terms of frames. So setting the center just doesnt work with auto layout. It's all about how views are related to each other.

这篇关于动画/下自动布局的使用移动视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆