Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <code>topLayoutGuide</code> and <code>bottomLayoutGuide</code> properties are inherited from <a href="https://developer.apple.com/library/ios/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instp/UIViewController/topLayoutGuide">UIViewController</a> and implements the <a href="https://developer.apple.com/library/ios/documentation/uikit/reference/UILayoutSupport_Protocol/Reference/Reference.html#//apple_ref/occ/intf/UILayoutSupport">UILayoutSupport</a> protocol. They are designed to be used with <code>AutoLayout</code>, but can also be used directly without the use of <code>AutoLayout</code>. </p> <p>In the case of <code>topLayoutGuide</code>, the property indicates the highest vertical extent for content that you don't want to appear behind a translucent or transparent UIKit bar (such as a status or navigation bar). So, if your view controller has been pushed onto a <code>UINavigationController</code> stack, <code>topLayoutGuide</code> will tell you how many points from the top of the screen the status bar and navigation bar cover. You can use this value scroll content in a <code>UIScrollView</code> to just below the navigation bar or ensure other content in your view isn't being covered by the <code>UINavigationBar</code>.</p> <p>Keep in mind that the value of <code>topLayoutGuide</code> depends on the view controller and whether or not it's contained within another view controller. From Apple's <code>UIViewController</code> documentation: </p> <blockquote> <p>The object that constrains the value for this property depends on whether or not the view controller is a child of a container view controller (such as a navigation or tab bar controller), as follows:</p> <p>• A view controller not within a container view controller constrains this property to indicate the bottom of the status bar, if visible, or else to indicate the top edge of the view controller's view. </p> <p>• A view controller within a container view controller does not set this property's value. Instead, the container view controller constrains the value to indicate: </p> <ul> <li><p>The bottom of the navigation bar, if a navigation bar is visible </p></li> <li><p>The bottom of the status bar, if only a status bar is visible </p></li> <li><p>The top edge of the view controller’s view, if neither a status bar nor navigation bar is visible</p></li> </ul> </blockquote> <p>Here's a piece of code I use to move a <code>UITextField</code> in response to the showing of the keyboard. I move the textfield to just below the navigation bar.</p> <pre><code>CGFloat length = self.topLayoutGuide.length; _feedback.frame = CGRectMake(_feedback.frame.origin.x, length + 5.0, _feedback.frame.size.width, _feedback.frame.size.height); </code></pre> <p>Using <code>bottomLayoutGuide</code> is exactly like using <code>topLayoutGuide</code>, except the <code>bottomLayoutGuide</code> refers to the lowest vertical extent for content. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload