Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a simple button to the middle of a navigation bar?

i found a lot of topics around placing buttons on navigation bar but none showed me how to place a button at the center of the bar. I found an example with a segmented control but i don't need that.

Just a button instead of the title. Is that possible? ;-)

Edit:

That will do it:

UIButton *titleButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[titleButton setFrame:CGRectMake(0, 0, 170, 35)];
self.navigationItem.titleView = titleButton;
like image 655
madmax Avatar asked Mar 25 '11 15:03

madmax


People also ask

How do I right align the navigation bar in HTML?

Right-Aligned Navigation Bar. The .navbar-right class is used to right-align navigation bar buttons. In the following example we insert a "Sign Up" button and a "Login" button to the right in the navigation bar. We also add a glyphicon on each of the two new buttons:

How to create a dropdown menu in the navigation bar?

How TO - More Button in Navbar 1 "More" Button in Navbar. Hover over the "More" link to see the dropdown menu. 2 Create A Dropdown Navbar. Create a dropdown menu that appears when the user moves the mouse over an element inside a... More ...

How to create a button navigation bar in WordPress?

There, you’re going to click on “Style” and choose the “button” option. Now, we just need to style it. If you want to make it the same as your primary navigation style, go ahead and add the font, the weight and the size of the letters that you used in your primary navigation bar.

How do I replace the navigation bar with a button?

In the following example the navigation bar is replaced by a button in the top right corner. Only when the button is clicked, the navigation bar will be displayed: Click on the button in the top right corner to reveal the navigation links. Add the required class names to create a default Navigation Bar.


1 Answers

You can set any custom view (e.g. UIButton) as a titleView property to your current navigationItem - that should do the trick.

like image 95
Vladimir Avatar answered Oct 14 '22 11:10

Vladimir