dzenbot / DZNSegmentedControl

A drop-in replacement for UISegmentedControl for showing counts, to be used typically on a user profile
https://www.cocoacontrols.com/controls/dznsegmentedcontrol
MIT License
1.58k stars 178 forks source link

Glue the SegmentedControl below the navigation bar ? #64

Open wongzigii opened 8 years ago

wongzigii commented 8 years ago

Great repo :+1: I just wondering is there an easy way to glue the segmentControl below navigation bar while scrolling? It will be great if there is an API to accomplish this.

dzenbot commented 8 years ago

Depends of your layout. If you're using UITableView or UICollectionView you can add the segmentedControl as a floating section header view and give the impression it's stick to the navigation bar.

Another approach, would be to create a custom UINavigationBar subclass and do the hard work of actually extending the view to host the segmentedControl.

dzenbot commented 8 years ago

This was an interesting challenge, so I took a few minutes to give it a try and it looks great. Have a look in this branch: https://github.com/dzenbot/DZNSegmentedControl/tree/navigation-bar-experiment

The only remaining bug is that the segmented control isn't reacting to touch events, for some reason.

image

wongzigii commented 8 years ago

Sounds wonderful. The first approach is a more easy way to achieve this.

pomarec commented 8 years ago

You can also have a look at https://github.com/bryankeller/BLKFlexibleHeightBar