带段控件和自定义标题视图的导航栏

Navigation bar with segment control and custom title view

如何创建一个带有段控件和自定义标题视图的导航栏,看起来像这样?

我假设 SegmentedControl 只是由于着色而看起来像是导航栏的一部分。我在这里的建议是使用 SegmentedControl 实现自定义视图,并将其放在 ViewController 的顶部,同时为自定义视图和 NavigationBar 使用相同的颜色。

对于自定义标题视图,您可以使用 UINavigationItem 的 titleView 属性:

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

查看此 link 并留意“自定义标题视图”: