Search code examples
iosuinavigationbaruisegmentedcontrol

Navigation bar with segment control and custom title view


How do I create a navigation bar with segment control and custom title view that looks something like this?

enter image description here


Solution

  • I would assume that the SegmentedControl only looks like its part of the navigation bar due to coloring. My suggestion here is to implement a custom view with a SegmentedControl and put it just at the top of your ViewController while using the same color for the custom view and the NavigationBar.

    For the custom title view you can use the titleView property of the UINavigationItem:

    self.navigationItem.titleView = view // <-- ´view´ is your custom title view
    

    See this link and look out for "Customize the Title View":