A simple paging view for iOS.
Available in [CocoaPods](http://cocoapods.org/?q= BSSegmentPagingView)
pod 'BSSegmentPagingView'
or
- Copy
BSSegmentPagingViewfolder to project; - Install
Masonryvia CocoaPods or other way.
#import "BSSegmentPagingView.h"
- Create a instance of
BSSegmentPagingView; - Add it to a superview;
- Setup its data source and delegate.
Implement necessary methods of BSSegmentPagingViewDelegate and BSSegmentPagingViewDataSource
Example implementation:
#pragma - mark BSSegmentPagingViewDelegate
- (void)bsPagingView:(BSSegmentPagingView *)pagingView didScrollToPage:(NSUInteger)pageIndex {
self.segmentControl.selectedSegmentIndex = pageIndex;
}
#pragma - mark BSSegmentPagingViewDataSource
- (NSUInteger)numberOfPageInPagingView:(BSSegmentPagingView *)pagingView {
return 3;
}
- (UIView *)pageAtIndex:(NSUInteger)index {
UIView *view = [[UIView alloc] init];
switch (index) {
case 0:
view.backgroundColor = [UIColor greenColor];
break;
case 1:
{
SecondPageViewController *secondPageVC = [[SecondPageViewController alloc] init];
[self addChildViewController:secondPageVC];
[secondPageVC didMoveToParentViewController:self];
return secondPageVC.view;
}
break;
case 2:
view.backgroundColor = [UIColor blueColor];
break;
default:
break;
}
return view;
}
