UIView Under Nav and Tab Bars - ios

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.

Related

Navigation bar is overlapping the UIView [Swift]

In the picture below, the navigation bar is overlapping the cardview. The whole screen is basically a view from a tab bar. On top is a navigationItem(the green one), then the navigationBar(the red one) and then the CardView.The translucent propery is set to false for the navigationBar but the CardView is still overlapped. I have unchecked the extendedLayout property to but that doesn't have any effect either.
Is there something else I can do to place the CardView below the navigationBar with padding?
You have to set the constraint on the top of the card view to the bottom of the top layout guide.

Hide Bottom Bar When Pushed through Autolayout

I have a UITabBarController with one UINavigationController holding a UIViewController as root view controller.
when tapping one of the button in the UIViewController, I push a regular chat window UIViewController (with TableView + Input View) end hiding the bottom tab bar. (using the "Hide bottom bar when pushed" flag)
In storyboard I added a regular UIView subclass to VC that look like a bottom bar, and I use Auto Layout to pin it to the bottom of the VC view.
The problem
when I push VC it takes a second for this view to pin to the bottom, it looks like auto layout pin it to the bottom as if the tab bar is not hidden and after a sec it recognise that the tab bar is hidden and moves it to the real bottom of the view.
For clear info check this screen shot
Now I will let you the know the constraints of the table view..
Now I am showing the constraints of the InputView
I am also adding my View hierarchy...
I had a similar issue in my project. I solved it by selecting the view I wanted anchored to the bottom (in your case, the input view), held Command, and selected its superview (both views should be highlighted now).
Then I selected the align button at the bottom of IB:
And added a Bottom Edges constraint.
What I had done initially is used the pin menu to pin the view to its superview, but it appears that will pin it to the bottom layout by default, which causes that weird movement during the transition.
EDIT:
After seeing the latest screenshot, the problem could lie in one of the superviews. I'm assuming that chatWindow is a UIView, and your Scroll View is horizontal only. Here's what your should check:
chatWindow is pinned to the scrollView's bottom similar to what I've outlined above.
scrollView is pinned to its superview as I've outlined above.
Moving the inputView outside of the scrollView to the root superview. Then one by one move it down the hierarchy towards its current location.

Navigation controller and ScrollView Top Layout Guide Margin

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.

What is the extend edge property in UIViewController for ?

I have read on the forums about this property, mostly its people setting this this property to false or unchecking it in the storyboard.
I have done this myself because when I have a UINavigation Controller embedded in a View, the top bar pushes my UITextView down so the text starts editing at the bottom.
Unchecking Extended Edges Under Top Bars in the StoryBoard in the UIViewController solves my problem but I don't understand what is going on.
Can someone give an explanation on what the purpose of this property is, I would like to know more about it.
By default, UITableViewController's views are automatically inset in iOS7 so that they don't start below the navigation bar/status bar. This is controller by the "Adjust scroll view insets" setting on the Attributes Inspector tab of the UITableViewController in Interface Builder, or by the setAutomaticallyAdjustsScrollViewInsets: method of UIViewController.
For a UIViewController's contents, if you don't want its view's contents to extend under the top/bottom bars, you can use the Extend Edges Under Top Bars/Under Bottom Bars settings in Interface Builder. This is accessible via the edgesForExtendedLayout property.
Reference: Why does UIViewController extend under UINavigationBar, while UITableViewController doesn't?
See the images below:
I set 44 height red topview and 44 height red footview of tableview.
UIRectEdgeTop: The top edge of the rectangle.
UIRectEdgeBottom: The bottom edge of the rectangle.
The edgesForExtendedLayout property, together with the extendedLayoutIncludesOpaqueBars property, determines whether or not view controllers' views underlap top and bottom bars (navigation bar, toolbar, etc.)

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