简体   繁体   中英

Change view width with autolayout and size class enabled

我已经为iPhone5s完成了示例屏幕的设置,并在swift中启用了自动布局和尺寸类别。我在屏幕顶部有一个视图(宽度为320)。如何为iPhone6和iPhone6Plus屏幕自动增加视图宽度。提前感谢。

You don't set the width. You make constraints to the left and right edges of the superview so it will always be the width of the screen (assuming that the superview is the controller's self.view).

如果您希望视图的尺寸遵循与其运行的iPhone相同的宽度,请在Interface Builder中放置视图,调整视图的大小,使其基本看起来像您想要的样子,然后添加约束,ctrl从您的视图拖动到其父视图,并添加“将空间引导到容器边距”和“将空间拖曳到容器边距”约束。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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