UiSegmentedControl on NavigationBar below Title

I am new to iOS Development, and something seemed to me during my work for the application that I am currently creating. I am trying to create a screen that will be aggravated by several ViewControllers, but on the NavigationBar I would like to have a UiSegmentedControl above the heading, something like a visibility bar to control navigation between the children of the ViewController. I wanted to create something similar to what we have on the HealthKit Dashboard:

enter image description here .

What approach do you propose to do? I understand that some questions have already been made about this, but after a long study I have not come to a conclusion.

During my research, I noticed that the UISearchBar in the navigation bar (to create the visibility bar) is only possible for UITableViewControllers , right? Therefore, I think this may not be the approach.

My next idea was to use the UISegmentedControl manually placed under the navigation bar and then use the Containment Api to switch to the different ViewControllers for this screen. The problem is here, I will have to duplicate the UISegmentedControl on all child ViewControllers. Is there a way to not duplicate this?

Another approach I've tried is to make my own UISegmentedControl header for the NavigationBar using the NavigationBar and UISegmentedControl below. I do not like this idea, and it did not succeed in trying to reproduce the NavigationBar.

Finally, another approach that I thought used was a UIPageViewController . Although this approach sounds good to me, I think I will also have to duplicate the UISegmentedControl .

In the end, I think the best solution is to have a UISegmentControl in the NavigationBar, but I don’t see how to implement this.

Do you think the best approach to my idea? I thought it would be easy, because this is the pattern that I see in many applications. Any suggestions?

I am doing this on Xcode 6.1.1 using Swift for iOS 8.

Many thanks for your help.

+7
ios ios8 swift uistoryboard
source share
1 answer

You can get this effect by adding a segment as a title and setting the desired tooltip. In the interface builder, it looks like this: enter image description here

+3
source share

All Articles