Navigation bar is overlapping the UIView [Swift] - ios

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.

Related

UIView overlapping with tab bar elements iOS

I made a view for a switch view. Now I already had tabbed menu buttons in it. The problem is the subview for the switch view seems to be overlapping with the tab bar icons at the bottom. Please help.
i think thats because your tabBar is set to translucent. set it to non-translucent from storyboard or programatically.
self.tabBarController.tabBar.translucent = false
You should have a constraint that sets the vertical space between your subview and your tabbar.
Also, check that your layout respects the iPhone X Safe Area (https://developer.apple.com/ios/human-interface-guidelines/overview/iphone-x/), from your image it seems that your elements overlap the safe area at the bottom.

Swift ios odd space when hiding navigation bar

When I hide my navigation bar I end up with some space under it, it looks like the status bar is twice as big as it should be.
In the image the red line is just touching where the statusbar/navigation bar ends.
My VC is contains a scroll view that is spaced 0 to the edges and spaced 0 to the top layout guide.
Why is the navigation bar not hiding completly? I thought that if you hide the navigation bar you would end up with a 20px statusbar showing only.
I could space my scrollview to be +20 from the top view but that seems a bit hacky.
Look for Extended Edges in attribute inspector of the view controller and uncheck Under Top Bars.

Can't get translucent navigation bar on tableviewcontroller. Works fine with view controller and tableview

I've got a gradient background that I want to show through both the navigation bar and the tab bar. I have them set to "translucent black". If I create a ViewController and put a TableView on it, this works perfectly. However, I can't get it to work properly with a TableViewController. The tab bar works fine, but the navigation bar ends up black. If I turn off "Adjust Scroll View Insets", then the navigation bar looks the way I want it, but the top half of the first table view row gets cut off (see examples). The gradient is on the background view. The background colour of the tableview is clear.
Is there any way to get the same effect on a TableViewController? Do I need to somehow make the heading or first row of the tableview be the background that goes under the nav bar?
ViewController with TableView added:
TableViewController with "Adjust Scroll View Insets" ON:
TableViewController with "Adjust Scroll View Insets" OFF:
After doing a test I think you'd need:
Adjusts Scroll View Insets ON
Extend Edges - Under Top Bars ON
No. 1 allow the UITableView to cover the entire screen (including under the navigation bar) and No. 2 adds a space at the top of the UITableView content so that the content is not hidden under the navigation bar.
I ran into a similar issue trying to set a full screen background on a static table view controller with a clear navigation bar. I solved it by using a backgroundView on my tableView instead of setting backgroundColor. For example:
myTableView.backgroundView = UIImageView(image: UIImage(named: "backgroundImg.png"))
I set my navigation bar to clear, but you could style that however you like:
navigationController?.navigationBar.backgroundColor = UIColor.clear
I also had to set Extend Edges - Under Top Bars ON

Embed a UIImageView in a bar widget either at the top or bottom of the screen

The navigation bar can take a UIImageView via the titleView property,
for example
self.navigationItem.titleView, and the The UIImageView can be animated.
Unfortunately, as per the documentation "Custom title views are centered on the navigation bar and may be resized to fit". This resizing makes it unsuitable for me.
My goal is to animate a UIImageView in something like a navigation bar, tab bar or toolbar. In other words I want to animate UIImageView in a bar that is always visible in a view.
How would I do this (using swift)?
A possible solution is to create a UIBarButtonItem with a UIImageView in the constructor and set the left or right button in the navigator bar to the animate button item.

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.

Resources