iOS 导航栏标题视图按钮

iOS Navigation Bar Title View Buttons

在 iOS 7+ 中,如何将导航栏标题视图设置为触发对视图控制器中的可变数组进行排序的一组操作?

例如: Yik Yak 的导航栏 http://i.stack.imgur.com/PcJNM.jpg

您可以使用 self.navigationItem.titleView 将导航栏标题设置为 UIView。例如:

UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:@[@"New", @"Hot"]];
[segmentedControl sizeToFit];
// Configure your segmentedControl to your liking...

self.navigationItem.titleView = segmentedControl;

另外,可以看看这个:UINavigationBar with buttons as title.基本上,你可以随意自定义titleView。