我在情节提要中的 UIViewController 中有一个 UIView,我想在该空间上添加一个约束,该视图距顶部边缘有一段距离.
I have a UIView in my UIViewController in storyboard which I want to add a constraint on to space that view a distance from the top edge.
现在,当我按常规按 ctrl + 拖动到 ViewController 的主视图时,我只能选择将其设置为顶部布局指南.
Now, when I do the usual by ctrl + drag to the ViewController's main view I only get option to set it to top layout guide.
这对我来说是个问题,因为在应用程序的某一时刻,我要将主视图向上移动 20-50 像素左右,然后发生的情况是我拥有的视图不会移动......因为它与超级视图不对齐.
This is a problem for me because at one point in the app Im going to move the main view up around 20-50px and what happens then is that view I have will not move... because its not aligned to superview.
如何在情节提要中手动执行此操作,还是必须以编程方式添加?
How can I manually do this in storyboard or do I have to add it programatically?
我使用的是 xcode 6.
Im using xcode 6.
约束常量值右侧有一个箭头.如果单击它,会弹出一个菜单,您可以在其中选择要相对于什么进行约束.如果您选择查看",它会将其固定在视图的顶部.
There is an arrow to the right of the constraint constant value. If you click on it, a menu pops out where you can choose what is it that you want to make your constraint relative to. If you choose 'View', than it will pin it to the top of the view.
这篇关于自动布局:将约束添加到超级视图而不是顶部布局指南?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!