How do I make a UISegmentedControl
as a part of an UINavigationBar
below it? Is it connected to the UINavigationBar
or is it a complete separate view just added as a subview to the UINavigationController
's view controller. Looks like it is part of the UINavigationBar
since there is a shadow below the bar.
It's a simple effect to accomplish.
First, place a segment in a toolbar. Place this toolbar right below the navigation bar. Set the delegate of the toolbar to your view controller, and return UIBarPositionTopAttached
in positionForBar:
. You can see in the store app, if you perform an interactive pop gesture, that the segment bar does not move the same as the navigation bar. That's because they are not the same bar.
Now to remove the hairline. The "hairline" is an UIImageView
that is a subview of the navigation bar. You can find it and set it as hidden. This is what Apple does in their native calendar app, for example, as well as the store app. Remember to show it when the current view disappears. If you play a little with the Apple apps, you will see that the hairline is set to hidden on viewWillAppear:
and set to shown in viewDidDisappear:
.
To achieve the style of the search bar, just set the bar's searchBarStyle
to UISearchBarStyleMinimal
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With