iOS UIViewPage 指示器 仿简书实现

UIIndicatorView

这是一个用于viewpage的一个索引指示器

pod install

target 'Pro' do
pod 'UIIndicatorView'
end

使用

可用于viewpage索引指标控件,可以参考下以下用法
### 例一

    UIIndicatorView *indicator = [[UIIndicatorView alloc] initUIIndicatorViewWithFrame:CGRectMake(10, 20, [UIScreen mainScreen].bounds.size.width - 40, 100) style:UIIndicatorViewDefaultStyle arrays:@[@"KESION", @"WENDYTING", @"TIPO", @"BLOW", @"SUCCESS"]];
    [self.view addSubview:indicator];


    UIIndicatorView *indicator2 = [[UIIndicatorView alloc] initUIIndicatorViewWithFrame:CGRectMake(10, 150, [UIScreen mainScreen].bounds.size.width - 40, 100) style:UIIndicatorViewLineStyle arrays:@[@"KESION", @"WENDYTING", @"TIPO", @"BLOW", @"SUCCESS"]];
    [self.view addSubview:indicator2];


这里写图片描述

例二

{
    [self.indicatorView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.addNewAttention.mas_bottom).offset(4);
        make.left.equalTo(self).offset(8);
        make.right.equalTo(self).offset(-8);
        make.height.mas_equalTo([self.indicatorView getUIHeight]);
    }];
    [_indicatorView addIndicatorItemByString:@"Tube最新内容"];
    [_indicatorView addIndicatorItemByString:@"推荐"];
    [_indicatorView addIndicatorItemByString:@"关注专题"];
    [_indicatorView addIndicatorItemByString:@"关注连载"];
    [_indicatorView addIndicatorItemByString:@"关注作者"];

    [self.indicatorView setShowIndicatorItem:0];

}
- (UIIndicatorView *)indicatorView
{
    if (!_indicatorView) {
        _indicatorView = [[UIIndicatorView alloc] initUIIndicatorViewWithIndicatorColor:kTUBEBOOK_THEME_NORMAL_COLOR font:Font(12)];
    }
    return _indicatorView;
}

如果你想有动画效果那么需要对UIScrollerView进行监听,且在delegate中加下面的代码

#pragma mark - UIScrollViewDelegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
   [self.tubeNavigationView.indicatorView changeIndicatorIndexByScrollerView:scrollView];
}


这里写图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
一个类似于安卓ViewPager的开源库 - iOS ViewPager 高级库 支持 iPhone/ipad/ipod 相关方法 pragma mark - version 1.0 /** * 初始化 YFViewPager的方法 * * @param frame frame * @param titles 标题数组 * @param views 视图数组 和标题数组一一对应 * * @return YFViewPager */ - (id)initWithFrame:(CGRect)frame titles:(NSArray *)titles views:(NSArray *)views; /** * 设置选择的菜单按钮 * * @param index 按钮的索引值 从左到右一次是0,1,2,3... */ - (void)setSelectIndex:(NSInteger)index; /** * 点击菜单按钮时 调用的block方法 * * @param block 返回YFViewPager本身和点击的按钮的索引值,从左到右一次是0,1,2,3... */ - (void)didSelectedBlock:(SelectedBlock)block; pragma mark - version 2.0 /** * 初始化 YFViewPager的方法 也是目前使用的YFViewPager的唯一初始化api * * @param frame frame * @param titles 标题数组 * @param icons 标题右侧图标数组 * @param selectedIcons 标题右侧选中时的图标数组 * @param views 视图数组 和标题数组一一对应 * * @return YFViewPager */ - (id)initWithFrame:(CGRect)frame titles:(NSArray *)titles icons:(NSArray *)icons selectedIcons:(NSArray *)selectedIcons views:(NSArray *)views; /** * 设置菜单标题左边的icon 图标 * * @param icons 图标image * @param selectedIcons 菜单被选中时显示的图标image */ - (void)setTitleIconsArray:(NSArray *)icons selectedIconsArray:(NSArray *)selectedIcons; /** * 设置菜单右上角小红点显示的文字,数组需与菜单一一对应,数字为0时 赋值 @0或@"" * * @param tips 小红点上的文字 */ - (void)setTipsCountArray:(NSArray *)tips;

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值