当前位置:   article > 正文

JXCategoryView使用

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;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21

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;
    }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/码创造者/article/detail/787377
推荐阅读
相关标签
  

闽ICP备14008679号