在IB中的GLKViewController中的Xcode 5中,顶部/底部布局指南是什么?

时间:2023-01-23 16:33:12

In Xcode 5 in a GLKViewController in IB what are the Top/Bottom Layout guides for? I've been reading through docs and can't seem to find it anywhere.

在IB中的GLKViewController中的Xcode 5中,顶部/底部布局指南是什么?我一直在阅读文档,似乎无法在任何地方找到它。

1 个解决方案

#1


6  

These are not specific to GLKViewController -- you'll see them in any view controller.

这些并不特定于GLKViewController - 您将在任何视图控制器中看到它们。

In iOS 7, views extend underneath the transparent status, navigation, and tab bars (if present) by default. Because you probably don't want your subviews ending up underneath these bars, the layout guides provide an easy way to set up layout constraints relative to wherever those bars end up.

在iOS 7中,默认情况下,视图会在透明状态,导航栏和标签栏(如果存在)下方展开。因为您可能不希望子视图最终位于这些条形图下方,所以布局指南提供了一种简单的方法来设置相对于这些条形图最终位置的布局约束。

For example, say you want a button to appear 20pt below the navigation bar. Where before you'd make a constraint between the button and the top of the view, you can now make a constraint between the button and the top layout guide. That view in the nib isn't responsible for setting whether the navigation bar is shown or how tall it is -- those things are controlled by the view controller that presents the view at run time -- so constraining to the top layout guide makes sure your button is in the right place regardless of how the view is presented.

例如,假设您希望按钮在导航栏下方显示20pt。在按钮和视图顶部之间进行约束之前,您现在可以在按钮和顶部布局指南之间进行约束。笔尖中的视图不负责设置导航栏是显示还是显示高度 - 这些内容由视图控制器控制,在运行时显示视图 - 因此限制顶部布局指南确保无论视图如何呈现,您的按钮都在正确的位置。

#1


6  

These are not specific to GLKViewController -- you'll see them in any view controller.

这些并不特定于GLKViewController - 您将在任何视图控制器中看到它们。

In iOS 7, views extend underneath the transparent status, navigation, and tab bars (if present) by default. Because you probably don't want your subviews ending up underneath these bars, the layout guides provide an easy way to set up layout constraints relative to wherever those bars end up.

在iOS 7中,默认情况下,视图会在透明状态,导航栏和标签栏(如果存在)下方展开。因为您可能不希望子视图最终位于这些条形图下方,所以布局指南提供了一种简单的方法来设置相对于这些条形图最终位置的布局约束。

For example, say you want a button to appear 20pt below the navigation bar. Where before you'd make a constraint between the button and the top of the view, you can now make a constraint between the button and the top layout guide. That view in the nib isn't responsible for setting whether the navigation bar is shown or how tall it is -- those things are controlled by the view controller that presents the view at run time -- so constraining to the top layout guide makes sure your button is in the right place regardless of how the view is presented.

例如,假设您希望按钮在导航栏下方显示20pt。在按钮和视图顶部之间进行约束之前,您现在可以在按钮和顶部布局指南之间进行约束。笔尖中的视图不负责设置导航栏是显示还是显示高度 - 这些内容由视图控制器控制,在运行时显示视图 - 因此限制顶部布局指南确保无论视图如何呈现,您的按钮都在正确的位置。