简体   繁体   English

XCode / Swift 3:如何在不破坏现有约束的情况下上下移动情节提要元素?

[英]XCode/Swift 3: How to shift storyboard elements down/up without messing up existing constraints?

XCode/Swift 3 XCode / Swift 3

I've placed several elements (eg labels, text Fields) on my story board, and I've properly set all constraints. 我在故事板上放置了几个元素(例如标签,文本字段),并且已经正确设置了所有约束。

Now I've decided that all content needs to shift down about five pixels. 现在,我决定所有内容都需要向下移动约五个像素。 I can press the COMMAND + A keys to select all and then press the down arrow five times on my keyboard to shift everything. 我可以按COMMAND + A键选择全部,然后按键盘上的向下箭头五次以移动所有内容。 However, that messes up all of my existing constraints! 但是,这弄乱了我所有的现有约束!

How can I shift everything down five pixels and preserve my constraints? 如何将所有内容下移5个像素并保留约束?

I'm very new to iOS programming, so thanks for your patience for what must be a very easy question for some of you! 我对iOS编程非常陌生,因此感谢您的耐心等待,对于您中的某些人来说,这一定是一个非常简单的问题!

after you shifted down all your items (like you've done) 下移所有项目后(如完成操作)

there is a button with which you can update all constraints 有一个按钮可以用来更新所有约束

在此处输入图片说明

If you shift elements down it will cause the constraints to update accordingly. 如果向下移动元素,将导致约束条件相应更新。 You should update all constraints, an easy way to do it is by selection the following option: 您应该更新所有约束,一种简单的方法是选择以下选项:

在此处输入图片说明

Select "Update constraints" and make sure you select "Apply to all views in container". 选择“更新约束”,并确保选择“应用于容器中的所有视图”。

Don't worry about it, First you have shifted all these downs now on storyboard left side there is a Document Outline Bar, on that your storyboard has a yellow arrow, click that and you will see all the shifted objects are presents with their properties. 不用担心,首先,您已在情节提要板上移动了所有这些下降,然后在情节提要板上显示了文档大纲栏,在情节提要上带有黄色箭头,单击该图标,您将看到所有已移动的对象及其属性都存在。 Click them one by one and and select 逐一单击它们,然后选择

Update Constraints 更新约束

This will set your constraints as you updated. 这将在更新时设置约束。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM