I need to implement a Swipeable UISegmentedControl in Swift. I have UISegmenttedControl view, but how can I make in swipeable like a tab bar in Android.
I have a git MIT licensed project HMSegmentedControl, but I am required to implement it standalone. I need a a simple guidance.
Use
UISegmentControlas Subview ofUIScrollViewI'm using
UIStoryboardto design my View. Please follow these steps.Step 1: Add
UIScrollViewto your storyboard.Step 2: The width of the
UIScrollViewshould be of View's width, height as approx 60px.Step 3: Add
UISegmentControlwith n Segments to theUIScrollView, the width of theUISegmentControlshould be of 100*n px (You can calculate based on your requirements).Step 4: Now, Add Outlet for
UIScrollViewin your ViewController.Step 5: Add contentsize for the
UIScrollView, following code in theviewDidLoadof your ViewControllerPlease do your own customizations for
UISegmentControl. I have tested the same & it is working for me.This should work for you!