JXCategoryView使用

1、首先父类VC使用JXCategoryView代理<JXCategoryViewDelegate, JXCategoryListContainerViewDelegate>
2、定义三个属性
@property (nonatomic, strong) NSArray *titleArr;// 标题数据
@property (nonatomic, strong) JXCategoryTitleView *categoryView;// 标题view
@property (nonatomic, strong) JXCategoryListContainerView *listContainerView;//listView
3、实例化属性
self.titleArr = @[@“图文素材”, @“视频素材”];

self.categoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake((kSCREEN_WIDTH - 300)/2, kStatusBarHeight, 300, categoryView)];
self.categoryView.titles = self.titleArr;
self.categoryView.titleSelectedColor = COLOR_Hex(0x2B61FF);
self.categoryView.titleFont = kFONT(18);
self.categoryView.titleSelectedFont = kFONT(18);
self.categoryView.titleLabelZoomScrollGradientEnabled = NO;
//self.categoryView.titleColorGradientEnabled = YES;
[self.view addSubview:self.categoryView];

JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
lineView.indicatorWidth = JXCategoryViewAutomaticDimension;
lineView.lineStyle = JXCategoryIndicatorLineStyle_Lengthen;
lineView.verticalMargin = 5;
lineView.indicatorColor = COLOR_Hex(0x2B61FF);
self.categoryView.indicators = @[lineView];

self.listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
self.listContainerView.frame = CGRectMake(0, kStatusBarHeight + categoryView, kSCREEN_WIDTH, kSCREEN_HEIGHT - kStatusBarHeight - categoryView);
[self.view addSubview:self.listContainerView];
//关联到categoryView
self.categoryView.listContainer = self.listContainerView;

4、代理JXCategoryViewDelegate

  • (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
    //侧滑手势处理
    self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0);
    NSLog(@"%@", NSStringFromSelector(_cmd));
    }

  • (void)categoryView:(JXCategoryBaseView *)categoryView didScrollSelectedItemAtIndex:(NSInteger)index {
    NSLog(@"%@", NSStringFromSelector(_cmd));
    }

5、代理JXCategoryListContainerViewDelegate

  • (id)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
    GraphicMaterialVC *list = [[GraphicMaterialVC alloc] init];
    if (index == 0) {
    list.view.backgroundColor = Color_RedColor;
    }else{
    list.view.backgroundColor = Color_BlueColor;
    }
    return list;
    }

  • (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
    return self.titleArr.count;
    }

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值