I'm trying to find a library or sample project for the sliding categories view that Etsy has in their iPhone app.
I'm talking about re-creating the "Handpicked, History, and Seasonal" categories swipe effect at the top of the app's main view.
If anybody knows of one on Github, or maybe a kickstart on how to do something like this, that would be awesome!
There's a similar control up on github at https://github.com/rs/SDSegmentedControl. They use a UISegmentedControl subclass to create the effect. Cocoacontrols.com is your friend. :)
If you want just the categories and not the whole TableView, then you don't need a 3rd party control. A UIScrollView is all you need.
The idea is you create a scrollview with Paging enabled and set it not to clip the contents and center it in the screen. Now because we need to be able to capture touches even beyond the left edge of the scrollView (when the user has scrolled already), we need a trick to capture the touches. This is done by using a UIView that will be in a full screen width and will pass a long the touches intercepted to our scrollView.
With that set, here is the code: First the View that captures the touches (I named it ExtendedScrollViewCaptureView):
Here is the implementation file:
Now lets go to the main thingy. Create a UIScrollView iVar in your viewController header file:
also add 2 integer variables that monitor the maximum titles available and keep track of the selected tab:
and in your implementation file:
Now create the function to init your ScrollView with the title labels (the labels being passed as an NSArray)
Now capture the UIScrollView scroll event, from the delegate:
finally we need the function to capture the title tap events:
That's it!