多层级条目展示表

关于如何展示多栏目多个条目多个cell多个collectioncell的展示类似下面这种情况

1536909708079.jpg

像这种比较复杂的样式,里面涵盖了SegmentTitleView UITableView UICollectionView 这几种类型,基本的层级关系是

SegmentTitleView 包含 SegmentTitleView 包含 UITableView
包含 UICollectionView 这样的样式

关于SegmentTitleView的使用可以直接参考 iOS自定义一个仿网易左右滑动切换页面框架

///默认选择
@property (nonatomic,assign) NSInteger defaultSelect;
@property (nonatomic, strong) FSSegmentTitleView *titleView;
///当前控制器
@property (nonatomic ,strong) UIViewController *currentVC;
@property (nonatomic, strong) NSMutableArray *childVCs;
self.titles = @[@"全部基金",@"自选基金"];

self.titleView = [[FSSegmentTitleView alloc]initWithFrame:CGRectMake(0, 0, self.titles.count*100, 40) titles:self.titles delegate:self indicatorType:FSIndicatorTypeNone];
    self.titleView.indicatorExtension = 6;
    self.titleView.selectIndex = _defaultSelect;
    self.titleView.titleFont = [UIFont systemFontOfSize:15];
    self.titleView.titleSelectFont = [UIFont boldSystemFontOfSize:15];
    self.titleView.titleNormalColor = RGBCOLOR(253, 149, 137);
    self.titleView.titleSelectColor = [UIColor whiteColor];
    self.navigationItem.titleView = self.titleView;
//  切换各个标签内容
- (void)replaceController:(UIViewController *)oldController newController:(UIViewController *)newController
{
    /**
     *            着重介绍一下它
     *  transitionFromViewController:toViewController:duration:options:animations:completion:
     *  fromViewController      当前显示在父视图控制器中的子视图控制器
     *  toViewController        将要显示的姿势图控制器
     *  duration                动画时间(这个属性,old friend 了 O(∩_∩)O)
     *  options                 动画效果(渐变,从下往上等等,具体查看API)
     *  animations              转换过程中得动画
     *  completion              转换完成
     */
    [self.view addSubview:newController.view];
    [newController.view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    [self addChildViewController:newController];
    if (![[UIApplication sharedApplication] isIgnoringInteractionEvents]) {
        [[UIApplication sharedApplication] beginIgnoringInteractionEvents];
    }

    [self transitionFromViewController:oldController toViewController:newController duration:0.2 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
    } completion:^(BOOL finished) {
        if (finished) {
            [newController didMoveToParentViewController:self];
            [oldController willMoveToParentViewController:nil];
            [oldController removeFromParentViewController];
            self.currentVC = newController;
        }else{
            self.currentVC = oldController;
        }
        if ([[UIApplication sharedApplication] isIgnoringInteractionEvents]){
            [[UIApplication sharedApplication] endIgnoringInteractionEvents];
        }
        
    }];
}


#pragma mark FSSegmentTitleViewDelegate
- (void)FSSegmentTitleView:(FSSegmentTitleView *)titleView startIndex:(NSInteger)startIndex endIndex:(NSInteger)endIndex
{
    // childVC里放置的是对应的那些子页面的VC
    UIViewController *newVC = self.childVCs[endIndex];
    [self replaceController:self.currentVC newController:newVC];
}

这就是第一层的titleVC的基本展示了,接下来第二层titleview的配置也参照第一层,但是要相应的改变titles的数量。这里就不过多赘述了

你可能感兴趣的:(多层级条目展示表)