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;
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 - 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 ...
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.
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.
You can set any custom view (e.g. UIButton) as a titleView
property to your current navigationItem - that should do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With