Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using navigation bar on tab bar controller

I am new in xcode. I use xcode 7.

I am trying to add a navigation bar on tab bar controller.

enter image description here

in that screenshot, i selected top translucent bar black but it doesn't appear when i run the project

My main purpose is to show a top bar and add an image (logo) on it.

How can i achieve this ?

like image 994
Utku Dalmaz Avatar asked Oct 05 '15 12:10

Utku Dalmaz


People also ask

How do I add a tab bar to my navigation controller?

To add a tab, first drag a new View Controller object to the storybard. Next control-drag from the tab bar controller to new view controller and select view controllers under Relationship Segue . Your tab bar controller will update with a new tab.

What is the difference between a tab bar and a navigation bar?

The Tab Bar It is usually present on most pages within an app and has the same disadvantages as the navigation bar. One important difference between tab bars and navigation bars is that tab bars are persistent, that is, they are always visible on the screen, whether the user scrolls down the page or not.

What is the use of tab bar controller?

A tab bar controller keeps a reference to its child view controllers. We can access that array through the viewControllers property of the tab bar controller. That's part of the solution. In the viewDidLoad() method of the TabBarController class, we invoke a helper method, setupChildViewControllers() .

How do I add a Viewcontroller to the tab bar controller in storyboard?

To add the new View Controller to the Tab Bar Controller, right-click the Tab Bar Controller and drag it to the new View Controller. Select Relationship Segue. Now, the Tab Bar Controller has the third item and Relationship “view controllers” to “View Controller”.


1 Answers

Your format is not correct. please add Navigation Controller in your tab controller.

Select your ViewController and Click Editor > Embed In > Navigation Controller

like this :

enter image description here

Add navigation controller like this :

enter image description here

I hope its work for you.

Add image to your navigation bar :

var image = UIImage(named: "abc.jpg") as UIImage
self.navigationController.navigationBar.setBackgroundImage(image, 
                                                   forBarMetrics: .Default)
like image 96
Jay Bhalani Avatar answered Sep 21 '22 10:09

Jay Bhalani