can anybody help with the code on how to add segmented control within the navigation bar....i have seen it on some applications and want to implement it
thanks
A segmented control is a linear set of two or more segments, each of which functions as a button. Within a segmented control, all segments are usually equal in width. Like buttons, segments can contain text or images.
To switch between the child view controllers, we use a segmented control. Click the + button in the top right to bring up the Library and add a segmented control to the navigation bar of the master view controller. Open MasterViewController. swift and create an outlet for the segmented control.
Do you want to use Interface Builder or do it in code only?
With IB operation is very straightforward, you only need to drag segmented control to place on navigation bar where title is located. Title will be replaced by the segmented control.
If you want to accomplish this in code, please refer to this section of iPhone reference library. It seems you need to set navigation item's titleView
property to your segmented control, which is subclass of UIView, so this is completely legal.
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