【问题标题】:Navigation bar with segment control and custom title view带有段控制和自定义标题视图的导航栏
【发布时间】:2020-07-22 12:43:29
【问题描述】:

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

【问题讨论】:

    标签: ios uinavigationbar uisegmentedcontrol


    【解决方案1】:

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

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

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

    查看此链接并注意“自定义标题视图”:

    【讨论】:

    • 谢谢。你是对的! SegmentedControl 与导航栏分离!这样做也是为了实现它。
    猜你喜欢
    • 1970-01-01
    • 2017-01-17
    • 1970-01-01
    • 2012-01-16
    • 1970-01-01
    • 2019-11-05
    • 1970-01-01
    • 2020-02-10
    • 1970-01-01
    相关资源
    最近更新 更多