alionthego
alionthego

Reputation: 9703

segmentedControl in navigationBar above title swift4/xcode9/ios11

I am trying to mimic the behaviour of the Apple missed call screen with a segmented control above the title in a large title navigation bar.

So the segmented control will be above the title when the bar is large and when the view is scrolled such that the large bar becomes small, the title disappears and the segmented control remains. Exactly like the iOS missed calls screen

Upvotes: 3

Views: 1655

Answers (2)

gorkem
gorkem

Reputation: 530

Programmatically, you simply do the following:

self.navigationItem.title = @"Title";
self.navigationItem.titleView = self.segmentedControl;

On iOS 10 and lower, only the SegmentedControl is displayed in the NavigationItem.

Upvotes: 4

alionthego
alionthego

Reputation: 9703

So apparently it's quite easy. Just drag a segmented control into the navigationBar in storyboard and also add the name for the title of the navigationBar either programmatically or in the title field of the navigationBar in the inspector in storyboard.

Upvotes: 1

Related Questions