0

How can I make a UISegmentedControl as a part of an UINavigationBar below it just like the App Store Connect? Looks like it is part of the UINavigationBar since there is a shadow below the bar. Besides, the VC passes the segment control to the next when it push another VC. I think, there must be a customised transition in there project.

I also found the search bar in Contacts has the same appearance.

I found a question about the similar topic. But the highest votes answer confused me how to implement it. Moreover, it does not look like the segment control in App store connect. UISegmentedControl below UINavigationbar in iOS 7

aashish tamsya
  • 4,903
  • 3
  • 23
  • 34
Alex
  • 1
  • 1

1 Answers1

0

I find a solution myself, just share it here for someone may need this link. Here is code.

  1. Customize your Navigation Bar which is inherited by UINavigationBar
  2. Add frame observer on _UINavigationBarLargeTitleView and alpha observer on _UINavigationBarContentView sub title label to calculate color
  3. Init a UINavigationController with your Navigation Bar
  4. Add a UISegmentControl in a UIBarButtonItem
  5. Init a UIToolbar with the Bar Button Item and set it to be the first section header of a table
  6. Set the toolbar top shadow line to nil and add another one to the bottom
  7. Assign your navigation bar block to update the toolbar tint color and the shadow line alpha value

The result is not 100% the same as App Store Connect but met my request for temporary.

And I think the best way is to implement your customised Navigation bar.

Alex
  • 1
  • 1