ios分页组件-MDPageControl

MDPageControl

When I want to use the paging component of UIScrollView, I found that there is no suitable. So I wrote a custom paging components, it is very convenient to use very simple. Now shared to you, you can also give me some advice, thank you for using!!!

Usage

//选中的图片是点
    self.pageControl = [[MDPageControl alloc] initWithType:self.scrollView type:MDPointTypePoint];
    //选中的图片是块
//    self.pageControl = [[MDPageControl alloc] initWithType:self.scrollView type:MDPointTypeBlock];
    //默认选中的图片是点
//    self.pageControl = [[MDPageControl alloc] initWithScrollView:self.scrollView];
    //默认选中的图片是点, 并且设置pageControllView离scrollView底部的距离,默认为25
//    self.pageControl = [[MDPageControl alloc] initWithBottomPadding:self.scrollView padding:25];
    //设置选中的图片是点或者块, 并且设置pageControllView离scrollView底部的距离,默认为25
//    self.pageControl = [[MDPageControl alloc] initWithTypeAndBottomPadding:self.scrollView type:MDPointTypeBlock padding:25];
    //设置自定义图片,图片大小可参照我提供的图片大小 2x(14x14) 1x(7x7) 3x(21x21)
//    self.pageControl = [[MDPageControl alloc] initWithPointImages:self.scrollView normalImage:@"point_normal" selectedImage:@"point_selected"];
    //设置自定义图片,并设置pageControllView离scrollView底部的距离,默认为25
//    self.pageControl = [[MDPageControl alloc] initWithPointImagesAndPadding:self.scrollView normalImage:@"point_normal" selectedImage:@"point_selected" padding:25];
    //设置分页数
    [self.pageControl setPageNum:3];
    //显示pageControllView
    [self.pageControl show];

###Block

    //点击小点block
    [self.pageControl didSelectMDPageIndexBlock:^(NSInteger pageIndex) {
        [self.scrollView scrollRectToVisible:CGRectMake(pageIndex*SCREEN_WIDTH, 0, SCREEN_WIDTH, 175.f) animated:YES];
    }];

###Delegate

    //可以设置delegate,当点击小点时,执行delegate方法
    self.pageControl.delegate = self;

//MDPageControlDelegate 方法
- (void)didSelectMDPageIndex:(NSInteger)pageIndex {
    [self.scrollView scrollRectToVisible:CGRectMake(pageIndex*SCREEN_WIDTH, 0, SCREEN_WIDTH, 175.f) animated:YES];
}

###Other If you want to change the distance between points, you can modify the MDPageControl.h file

//distance between points
//圆点之间的间距
#define POINT_DISTANCE 10.f

###Point (分页控件展示-圆点) ###Block (分页控件展示-块) ##Source Code [传送门] MDPageControl

转载于:https://my.oschina.net/allwang/blog/851895

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值