Eli_Rozen
Eli_Rozen

Reputation: 1301

Adding segment controller on navigation bar in the second row

I want to add a segment controller to the navigation bar not as the title, but like this: enter image description here

How can I do that?

Upvotes: 8

Views: 4020

Answers (2)

Bruno Gama
Bruno Gama

Reputation: 120

I've had to do the same and simply added the segmented control inside a view added under the navigationbar bottom.

Upvotes: 0

Mick MacCallum
Mick MacCallum

Reputation: 130222

The problem is that it looks like this uses the navigation bar's title, which is actually in the same place as where you want your segmented control to go. Instead, you need to add a "prompt" to the navigation bar to increase the height of the bar, and add the prompt text above the content area of the bar.

This can be done purely in Interface Builder as illustrated by the screenshot below, or programmatically using the following code:

[self.navigationController.navigationItem setPrompt:@"some prompt text"];

enter image description here

Upvotes: 2

Related Questions