简体   繁体   English

Xcode 6 Interface Builder如何使UIView的宽度为100%?

[英]Xcode 6 Interface Builder how do I make a UIView 100% width?

Really basic question here I'm going through the docs and Apple videos but are yet to find out how to do it. 真正的基本问题是,我正在阅读文档和Apple视频,但尚未找到如何做的方法。

In Xcode 6 / iOS7/8 I have a UIview that I have dragged on an existing View sitting inside a new default ViewController. 在Xcode 6 / iOS7 / 8中,我有一个UIview,已将其拖到位于新默认ViewController内的现有View上。

All I want to do is in "Interface Builder" make this UIView I have dragged onto the screen "fill to 100% of the layout width", much like one would do with a webpage 100% width div wrapper, so that it automatically resizes its width on each device/layout it goes to. 我要做的只是在“界面生成器”中,使此UIView我已拖到屏幕上“填充到布局宽度的100%”,就像使用网页100%宽度的div包装器一样,以便它自动调整大小它在每个设备/布局上的宽度。

What settings do I need to change to do that???, I don't seem to be able to figure it out. 为此,我需要更改哪些设置????,我似乎无法弄清楚。

I have been experimenting with constraints and size classes etc. 我一直在试验约束和尺寸等级等。

Any help would be great 任何帮助都会很棒

Create a constraint for all size classes that has an equal width to the ViewController. 为所有尺寸类创建一个约束,该约束与ViewController的宽度相等。 Or you can have contraints between the leading and trailing spaces with a constant equal to 0. 或者,您可以在前导空格和尾随空格之间使用常数等于0的约束。

With the size classes you can have different constraints for different size classes. 使用尺寸类别,您可以对不同的尺寸类别具有不同的约束。 Ensuring these constraints are set in the "Base" size class means it will affect all size classes unless constraints for that specific size class are changed. 确保在“基本”尺寸类别中设置这些约束意味着这将影响所有尺寸类别,除非更改了该特定尺寸类别的约束。

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

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