Navigation controller and ScrollView Top Layout Guide Margin - ios

I am trying to align a "view" at the top of the screen but below the navigation bar. The view is inside a scrollview. The problem is that there is a gap at the top, where the top layout guide is not honored. I am writing this in Swift. Any solutions? I am attaching a photo of what's going on.
Basically, I want to remove the white part between the navigation controller and the blue background.
I also adding a snapshot of the constraints.

Related

UIView Under Nav and Tab Bars

Using storyboard and Swift, I have a view controller which has two elements on it. A UITextField, and a UIView, which I use merely to give a colored border to the UITextField. The UITextField is a child of the UIView. See:
The problem I am having is that despite having set the top bar and bottom bar simulated metrics attributes to Opaque Navigation Bar and Opaque Tab Bar respectively, See:
When the app builds and runs the top of the UIView is always underneath the nav bar. My over all feeling is that this is somehow a constraints issue but I have not been able to find the solution to it. How do I set the constraints so that the UIView is always immediately underneath the nav bar, and the bottom of the view is always just on top of the tab bar?
Select your UIView in storyboard and assign constraints to the top margins and to bottom margins. There is a 'Pin' button you use to do this that looks something like a Tie-Fighter ship in Star Wars, it is located at the bottom right of your storyboard view.
This will set margins to stretch to top and bottom always.
That is what the layout guides are for. Pin the top to the Top Layout Guide and the bottom to the Bottom Layout Guide. The guides will always move to adjust for any top and bottom bars.

How to create space between UINavigationBar and top of UITableView

I have a UITableView in my storyboard. I put a navigation bar at the top of the view. However the title seems to close to the top of the view near the time and battery. Is there any way to create spacing like in the view to the left of that one? I tried simply dragging the navigation bar down but it seems pinned to the top of the view. Any help is appreciated. Thanks!
If you are using autolayout (which I very much recommend), you are just missing a Vertical Space Constraint between your container view and your table view.
See the size inspector (as shown below) for a list of constraints on a UI element, or browse your Document Outline for missing constraints.

Top Layout Guide won't start at top of screen in Xcode 6 storyboard

I have 2 view controllers setup identically in a Storyboard. On one, the top layout guide goes all the way to the top (under the status bar), on the other the top layout guide starts just below the status bar.
On both view controllers, I have Extend Edges Under Top Bars (checked) and Adjust Scroll View Insets ->unchecked (not that I'm using a scroll view here).
I can't figure out why these are different in the storyboard, and thus at run time one view controller looks like the way it was designed, the other does not because items with constraints to that top layout guide will be 20px wrong.
Help.

What is the proper way to add a view to a view controller and make it cover it completely through rotations using Auto Layout?

Say I have a UIViewController and I want to add a red UIView atop it that covers its view completely using Auto Layout.
My first instinct was to pin it to every edge of the view controller's view, but due to the iOS 7 nature of view controller views extending underneath the nav bars, pinning it with a constant of 0 doesn't put it under the nav bars. And if I put -64 to cover it in portrait, that's not the correct constant for landscape as the nav bar is shorter.
How should I be implementing this?
Make sure your view is pinned to the top of the super view, not the top layout guide. It sounds like it's currently pinned to the top layout guide.
If it is pinned to the top layout guide, the best way to fix it is to delete the constraint, select the view, click the "Pin" tool at the bottom right of IB, and then select the top with a setting of zero.
This works fine in Xcode 5.1.1, but was a little buggy in earlier versions. Control+Drag onto the view generally forces you to select the top layout guide instead of the top of the view.

ios 7 UINavigationBar is above content when using Auto Layout

I am using Auto Layout in a storyboard to position a UICollectionView. I have created a vertical spacing between Top Layout Guide and the CollectionView. But the collection view still starts underneath the navigation bar. Even the prototype cell also has extra padding. Please see images below.
Interface Builder:
Simulator View:
The content should start below the navigation bar but as the user scrolls the content should go under the navigation bar. How do I accomplish this?
In your storyboard go to View Controller properties, and make sure that Under Top Bars option is unchecked.
Also in most cases you want to have opaque navigation bar.

Resources