之前的那版,刚发布,马上就有朋友给出了宝贵意见。不得不说,与人分享是一件令人高兴的事。^-^
这不今天得空,就将原来的封装了一下。自我感觉还可以,如有不足,还希望各位朋友能不吝赐教;

实现这个功能其实很简单,只要俩步:
First of all ,将demo下载下来,将HSFTableView文件夹 拖入您的工程


第二步, 自定义一个控制器继承于 HSFNestVC ,在viewDidLoad里添加:

【注意】VC1 VC2 VC3 要继承与HSFBaseTableVC
Finally, 就这样 完了。 简单吧。赶快试试吧^-^
demo地址: https://github.com/SeriouslyFunny/HSFTableViewDemo
网友评论
//
// MLMSegmentManager.m
// MLMSegmentPage
//
// Created by my on 2017/2/5.
// Copyright © 2017年 my. All rights reserved.
//
#import "MLMSegmentManager.h"
@implementation MLMSegmentManager
+ (void)associateHead:(MLMSegmentHead *)head
withScroll:(MLMSegmentScroll *)scroll
completion:(void(^)())completion {
[MLMSegmentManager associateHead:head withScroll:scroll completion:completion selectEnd:nil];
}
+ (void)associateHead:(MLMSegmentHead *)head
withScroll:(MLMSegmentScroll *)scroll
completion:(void(^)())completion
selectEnd:(void(^)(NSInteger index))selectEnd {
NSInteger showIndex;
showIndex = head.showIndex?head.showIndex:scroll.showIndex;
head.showIndex = scroll.showIndex = showIndex;
head.selectedIndex = ^(NSInteger index) {
[scroll setContentOffset:CGPointMake(index*scroll.width, 0) animated:YES];
if (selectEnd) {
selectEnd(index);
}
};
[head defaultAndCreateView];
__weak typeof(head) weakHead = head;
scroll.scrollEnd = ^(NSInteger index) {
[weakHead setSelectIndex:index];
if (selectEnd) {
selectEnd(index);
}
};
scroll.animationEnd = ^(NSInteger index) {
[weakHead animationEnd];
};
scroll.offsetScale = ^(CGFloat scale) {
[weakHead changePointScale:scale];
};
if (completion) {
completion();
}
[scroll createView];
UIView *view = head.nextResponder?head:scroll;
UIViewController *currentVC = [view viewController];
currentVC.automaticallyAdjustsScrollViewInsets = NO;
}
- (void)dealloc {
NSLog(@"✅%@",NSStringFromClass([self class]));
}
@end