自动布局:加约束的SuperView而不是顶部布局指南? [英] Autolayout: Add constraint to superview and not Top Layout Guide?

查看:209
本文介绍了自动布局:加约束的SuperView而不是顶部布局指南?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的故事板的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-50px移动主视图和发生了什么,然后就是认为我不会动...因为它不是对准上海华。

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?

林用x code 6。

Im using xcode 6.

推荐答案

您应该能够通过突出故事板所需的视图,然后选择编辑&GT做到这一点;管脚和GT;顶层空间,以上海华在顶部的菜单。

You should be able to do it by highlighting the view you want in the storyboard and then selecting Editor > Pin > Top Space to Superview in the top menu.

这是在X code 7过时,看到@ PaulGurov的回答吧。

This is outdated in XCode 7, see @PaulGurov's answer instead.

这篇关于自动布局:加约束的SuperView而不是顶部布局指南?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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