How to add navigation bar button without using navigation controller from storyboard? - ios

I'm having issues adding navigation bar button to a UINavigationBar directly without using UINavigationController.
The way it appears when using with UINavigationController on iPhoneX, is different from what it looks when i directly add an UINavigationBar.
Even if i set the height of navigationBar manually, the background color and bar button still stick to the top.
Using UINavigationBar
After adjusting height or even using SafeAreaInset to set bar height
using UINavigationController -> desired result

Related

Change location of Navigation Bar

When using the Navigation Controller it creates a new Navigation Bar on my first view controller. Intead of that bar being at the top of my screen I would like it to be on bottom. Is this possible? If not can I switch to using a different Nav Bar?
Navigation Bars are always at the top of view controllers, and cannot be moved. You could explore a TabBar or ToolBar though, depending on what you want.
Navigation Bar always appear on the top of your UIViewController when embedded in a UINavigationController. You cannot move it to any other position.
Still if you want to achieve such a requirement,
Hide the default UINavigationBar
self.navigationController?.navigationBar.isHidden = true
Create a custom UIView of same height(44) as the UINavigationBar and pin it to the bottom of your controller.

UICollectionView scroll changes color of navigation and tab how

I am building an iOS application and have done all the layouts using storyboards and auto layout.
I have a ViewController as follows
For the CollectionView I have specified it to have 4 cells.
The issue I'm having that when I scroll vertically, the background colour of the Navigation bar and Tab bar changes.
How can I make sure that the background colour is not changed when I scroll.
This is what happening when I scroll - You can see the background colour of the navigation and tab bar change.
your navigation bar and tab bar translucent bydefault so add this this code
self.navigationController.navigationBar.translucent = NO;
self.navigationController.tabBarController.tabBar.translucent = NO;
As suggested you can set the toolbar and navigation bar's translucent property to false, but you can also do this in the storyboard:

Why is my UINavigationBar hidden behind the top navigation bar in iMessage?

I have an iMessage extension and I want to make a UI with a UINavigationBar on top. I made a UINavigationBar via a UINavigationController in the storyboard. The bar looks fine in compact presentation style but when I switch to expanded it gets hidden behind the top bar in iMessage. I have had this issue in the past and resolved it by setting the top space to top layout guide to 0. However, I don't think I can constrain a UINavigationBar. Any advice?

How to make tab bar lay over content in Swift?

I want my tab bar to be translucent and blur the content behind it, but when I set its color to clear color it turns black instead. Currently I have my tab bar created programmatically in the app delegate. I made a class function called getTabBarController and configured my tab bar in there, and I call it in app delegate to return the tab bar. At last, I write
let vc = TabBarInitializer.getTabBarController()
self.window!.rootViewController = vc. Am I creating my tab bar incorrectly? How do I make the tab bar be on top of my content so that the translucent effect works?
You have place view or content behind tabbar which you have to show instead of black.
So when tab transparent, view behind the tabbar become visible.

UINavigationItem Transparency

I have a UINavigationItem (not a UINavigationBar) that I would like to make transparent or not opaque. This gets created when I make a relationship segue root view controller from a Navigation Controller to my UIViewController subclass.
I tried to embed it in a UINavigationBar, but couldn't make that work. There do not appear to be any methods for UINavigationItem that would allow me to change the appearance of its background.
Is there any way to accomplish this, either by embedding it inside a view of some sort or by getting a pointer to some object that has this capability?
Here is the storyboard that shows the hierarchy of the view controller. You can see the UINavigationItem as a direct descendant of the view controller. Notice that there is no explicit reference to a UINavigationBar:
Here is an image of the navigation section at the top of my UIViewController when it renders. I'd like to change the light gray to match the dark gray that you can see just below it:
From the docs:
In iOS 5.0 and later, you can customize the appearance of the bar using the methods listed in Customizing the Bar Appearance. You can customize the appearance of all navigation bars using the appearance proxy ([UINavigationBar appearance]), or just of a single bar.
In iOS 7, a navigation bar’s tintColor affects the color of the back indicator image, button titles, and button images. The barTintColor property affects the color of the bar itself. Additionally, navigation bars are translucent by default. Turning the translucency off or on does not affect buttons, since they do not have backgrounds.

Resources