Add segmented control to navigation bar and keep title with buttons

后端 未结 8 2450
借酒劲吻你
借酒劲吻你 2020-12-04 10:03

I want to add segmented control to the navigation bar but also keep the title and buttons, like in iOS 7 Appstore purchased section (example)

I have tried adding seg

相关标签:
8条回答
  • 2020-12-04 10:47

    Try to create UINavigationBar subclass and let it conform to UIToolbarDelegate protocol. Then in -init method create your segment control, add it on UIToolBar and set its delegate to your custom UINavigationBar class. Then write this magic:

    - (UIBarPosition)positionForBar:(id <UIBarPositioning>)bar {
        return UIBarPositionTopAttached;
    }
    

    Good luck!

    0 讨论(0)
  • 2020-12-04 10:48

    I haven't fully implemented it but the following is what I plan to do. (ios7) This would be for having title and the buttons on the same nav bar side by side.

    In storyboard, add a blank view to the navigation bar. Then add a label and a segmented control to that view. This allows you to add any control you want to the nav bar. So far the UI works, just haven't wired it up. Just wanted to share what I have found so far.

    0 讨论(0)
提交回复
热议问题