BSSegmentPagingView 0.0.3

BSSegmentPagingView 0.0.3

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
发布上次发布2016年3月

juxingzhutou 维护。



  • juxingzhutou

一个简单的 iOS 分页视图。

Demo Gif

安装

CocoaPods 中可用

pod 'BSSegmentPagingView'

  1. BSSegmentPagingView 文件夹复制到项目;
  2. 通过 CocoaPods 或其他方式安装 Masonry

如何使用

步骤 1

#import "BSSegmentPagingView.h"

步骤 2

  1. 创建 BSSegmentPagingView 的实例;
  2. 将其添加到superview中;
  3. 设置其数据源和代理。

步骤 3

实现 BSSegmentPagingViewDelegateBSSegmentPagingViewDataSource 的必要方法

示例实现

#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;
}