在 Xcode 7 中固定两个 UIImage 视图之间的水平间距

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30812367/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 07:16:57  来源:igfitidea点击:

Pin Horizontal Spacing Between Two UIImage Views in Xcode 7

iosxcodexcode7

提问by Wyatt

I am a beginner using Xcode 7 beta, working off a tutorial that uses Xcode 6. In the tutorial, the instructor selects Editor, Pin, and Horizontal Spacing to pin the space between two images so that it stays the same when switching to landscape. In Xcode 7, the Editor menu doesn't include a Pin menu. Does anyone know how to pin horizontal spacing between two images in the new Xcode 7?

我是使用 Xcode 7 beta 的初学者,正在编写使用 Xcode 6 的教程。在教程中,讲师选择编辑器、固定和水平间距来固定两个图像之间的空间,以便在切换到横向时保持不变。在 Xcode 7 中,编辑器菜单不包括 Pin 菜单。有谁知道如何在新的 Xcode 7 中固定两个图像之间的水平间距?

回答by Inder Kumar Rathore

This is close to what you need

这接近你所需要的

You can choose View (current distance = 0)from the drop down menu

您可以View (current distance = 0)从下拉菜单中选择

Constrain image

约束图像



GIF

动图

回答by Laurent

Use the pin button at the bottom right corner of the storyboard view. It looks like a Tie-fighter icon.

使用故事板视图右下角的固定按钮。它看起来像一个领带战斗机图标。

You will also notice that Pinning two elements to each other for horizontal and vertical spacing is not there. Instead select the left item and add a right constraint. Then select the right one and add a left constraint. You will see the horizontal spacing indicator appearing between the two. YMMV.

您还会注意到,不存在将两个元素相互固定以实现水平和垂直间距的功能。而是选择左侧项目并添加右侧约束。然后选择右侧的并添加左侧约束。您将看到水平间距指示器出现在两者之间。天啊。

EDIT

编辑

If you are going thru the same tutorial (RW) as I am going thru, fear not! The control-drag between elements still works the same and brings the options XCode 6 shows in a similar way (ex: ctrl-drag from left to right way brings a popup menu with horizontal spacing.) I hope this helps.

如果您正在阅读与我正在阅读的教程 (RW) 相同的教程,请不要害怕!元素之间的 control-drag 仍然工作相同,并以类似的方式带来 XCode 6 显示的选项(例如:ctrl-drag 从左到右的方式带来一个带有水平间距的弹出菜单。)我希望这会有所帮助。

回答by saint_berzerker

Just to kind of clear this (good) answer up - select the left image, then the "pin" icon (tie fighter looking thing), click the right constraint icon at the top that looks like this:

只是为了清除这个(好的)答案 - 选择左侧图像,然后选择“大头针”图标(看起来像领带战斗机的东西),单击顶部的右侧约束图标,如下所示:

|--|

|--|

...leave the value of it where it is. Then click the "add constraints" button. Do the same for the right image. Then run the app and verify that it works.

...保留它的价值。然后单击“添加约束”按钮。对正确的图像执行相同的操作。然后运行应用程序并验证它是否有效。