[iOS]MJCSegmentInterface(分段控制器)
程序员文章站
2022-04-11 13:45:58
...
GitHub:https://github.com/MJCIOS/MJCSegmentInterface
个人使用了不短时间,感觉也非常好用。这是一款类似百思不得姐、今日头条、腾讯新闻等app的分段界面功能的,分段界面框架。如图:
这里只是简单的使用
#import "WorkZoneManagementSegment.h"
#import "MJCSegmentInterface.h"
#import "WorkZoneManagementListVC.h"
@interface WorkZoneManagementSegment () <MJCSegmentDelegate>
{
NSMutableArray * _vcArr;
NSMutableArray * _titleArr;
}
@property (nonatomic ,strong) MJCSegmentInterface * interface;
@property (nonatomic ,strong) NSMutableArray * columnArr;
@end
@implementation WorkZoneManagementSegment
- (void)viewDidLoad {
[super viewDidLoad];
[self settingNav];
[self requestColumn];
}
- (void)settingNav {
self.rm_navgationBar = [RMNavigationBar navWithTitle:@"工区管理" rightItem:@"" rightAction:^{
} backAction:^{
[self.navigationController popViewControllerAnimated:YES];
}];
}
- (void)initChildrenVC {
if (!_vcArr) {
_vcArr = [NSMutableArray array];
}
[_vcArr removeAllObjects];
if (!_titleArr) {
_titleArr = [NSMutableArray array];
}
[_titleArr removeAllObjects];
if (self.columnArr && self.columnArr.count > 0) {
for (WorkZoneManagementListModel *model in self.columnArr) {
[_titleArr addObject:model.workAreaName];
WorkZoneManagementListVC * vc = [WorkZoneManagementListVC initFromXib];
vc.columnModel = model;
[_vcArr addObject:vc];
}
}
[self setupInterfaceWithTitlesArr:_titleArr vcArr:_vcArr];
}
- (void)setupInterfaceWithTitlesArr:(NSArray*)titlesArr vcArr:(NSArray*)vcArr {
MJCSegmentInterface *interFace = [MJCSegmentInterface jc_initWithFrame:CGRectMake(0,NAVBARHEIGHT,SCREENWIDTH, SCREENHEIGHT - NAVBARHEIGHT) interFaceStyleToolsBlock:^(MJCSegmentStylesTools *jc_tools) {
jc_tools.
jc_titleBarStyles(MJCTitlesScrollStyle).
jc_titlesViewPenetrationEnabled(YES).
jc_itemTextNormalColor(HexColor(@"#7C8DB9")).
jc_indicatorColor(HexColor(@"#EE781B")).
jc_childScollBouncesEnabled(YES).
jc_childScollEnabled(YES).
jc_itemTextSelectedColor(HexColor(@"#314B91")).
jc_indicatorHidden(NO).
jc_itemTextFontSize(Fit(16)).
jc_titlesViewBackColor([UIColor whiteColor]).
jc_itemEdgeinsets(MJCEdgeInsetsMake(15, 10, 10, 10, 20)).jc_itemSelectedSegmentIndex(self.selectType).
jc_titlesViewFrame(CGRectMake(0, 0, SCREENWIDTH , 50)).jc_indicatorFrame(CGRectMake(0, 40, 28, 4));
}];
self.interface = interFace;
interFace.delegate = self;
[self.view addSubview:interFace];
[interFace intoTitlesArray:titlesArr intoChildControllerArray:vcArr hostController:self];
}
// 获取工区分栏
- (void)requestColumn {
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
dic[@"content"] = @{@"data":@{@"keyword":@""}};
[XCNetworking POSTWithURLCode:URLCODE_getWorkAreaList params:dic hudText:@"正在加载中..." success:^(XCBaseModel * response) {
if (response.code == kSuccess) {
NSDictionary *data = response.data;
if (data) {
NSArray * modelArr = [NSArray yy_modelArrayWithClass:[WorkZoneManagementListModel class] json:data[@"rows"]];
self.columnArr = [NSMutableArray arrayWithArray:modelArr];
}
}
[self initChildrenVC];
} failure:^(NSError *error) {
[self initChildrenVC];
}];
}
@end