竖着显示的“UIPageControl”

竖着显示的“UIPageControl”

 竖着显示的“UIPageControl”,其实是自己封装的一个UIButton 

原理:根据传入的page的个数利用for循环创建UIButton,默认的都是灰色!再创建一个红色UILabel,滑动scroll的时候,让UILabel跟着button的坐标走

//pageControl

- (void)customButton:(NSInteger)btnCount {

    NSInteger i = 0;

    NSMutableArray *arr = [NSMutableArray arrayWithCapacity:0];

    _arrBtn = [[NSMutableArray allocinitWithCapacity:0];

    for (; i<btnCount; i++) {

        UIButton *button= [UIButtonbuttonWithType:UIButtonTypeCustom];

        button.frame = CGRectMake(0, i*151010);

        button.clipsToBounds = YES;

        button.layer.cornerRadius = 5;

        button.tag = 1001+i;

        button.backgroundColor = [UIColor grayColor];

        

        [_viewPage addSubview:button];

        [arr addObject:button];

    }

    UILabel *label = [[UILabel allocinitWithFrame:CGRectMake(00,1010)];

    label.backgroundColor = [UIColor redColor];

    label.clipsToBounds = YES;

    label.tag = 3000;

    label.layer.cornerRadius = 5;

    [_viewPage addSubview:label];

    self.arrBtn = arr;

} 

一般UIPageControl是配合UIScrollView显示的,但是既然UIPageControl是竖着显示;那么UIScrollView也是竖着滑动的,滑动Scroll的时候,PageControl跟着滑动

scroll代理方法

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {    

    NSInteger tag = scroll.contentOffset.y/scroll.frame.size.height;

    UILabel *label = (UILabel *)[_viewPage viewWithTag:3000];

    label.frame = CGRectMake(0, tag*151010);

}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值