分页button

在自己的项目中频繁遇到分页button, 类似下图:

PageButtonView.gif

简单封装一个, 适合新手学习和使用, 代码地址:
PageButtonView

使用方法如下:

PageButtonView *pageButtonView = ({
        pageButtonView = [[PageButtonView alloc]initWithFrame:CGRectMake(0, 20, screen_width, 40) buttonTitles:buttonTitles];
        pageButtonView.backgroundColor = [UIColor groupTableViewBackgroundColor];
        pageButtonView.normalButtonColor = [UIColor grayColor];
        pageButtonView.selectedButtonColor = [UIColor redColor];
        pageButtonView.selectedLineColor = [UIColor blueColor];
        pageButtonView.selectedIndex = nextButton;
        pageButtonView.buttonTouchedBlock = ^(NSInteger index) {
            NSLog(@"点击了或选中了button%ld", (long)index);
        };
        pageButtonView;
    });
    [self.view addSubview:pageButtonView];

若有问题, 欢迎一起学习 一起成长~

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,898评论 25 709
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,266评论 4 61
  • 当我听到这句话的时候,我觉得我也应该是这样的人,但是我只是觉得我应该要成为这样的人,而我却没有做到这样的人。 这么...
    小龙虾爱吃虾阅读 472评论 0 1