ZATabBar 是一个 iOS 组件,用于创建无标签的 tabbar。
$ edit Podfile
platform :ios
pod 'ZATabBar'
$ pod install
在 ZATabBar 中有两个主要的类
ZATabBarController
- 表示管理 tabbar 的控制器。ZATabBar
- 表示 tabbar 的视图。ViewController *vc1 = [[ViewController alloc] init];
vc1.title = @"controller 1";
vc1.view.backgroundColor = [UIColor yellowColor];
UINavigationController *nc1 = [[UINavigationController alloc] initWithRootViewController:vc1];
ViewController *vc2 = [[ViewController alloc] init];
vc2.title = @"controller 2";
vc2.view.backgroundColor = [UIColor greenColor];
UINavigationController *nc2 = [[UINavigationController alloc] initWithRootViewController:vc2];
ViewController *vc3 = [[ViewController alloc] init];
vc3.title = @"controller 3";
vc3.view.backgroundColor = [UIColor whiteColor];
UINavigationController *nc3 = [[UINavigationController alloc] initWithRootViewController:vc3];
NSArray *tabVCArray = @[vc1, vc2, vc3];
NSDictionary *imgDict1 = @{
@"Normal": [UIImage imageNamed:@"tabBarAR"],
@"Active": [UIImage imageNamed:@"tabBarARActive"]
};
NSDictionary *imgDict2 = @{
@"Normal": [UIImage imageNamed:@"tabBarGuide"],
@"Active": [UIImage imageNamed:@"tabBarGuideActive"]
};
NSDictionary *imgDict3 = @{
@"Normal": [UIImage imageNamed:@"tabBarInfo"],
@"Active": [UIImage imageNamed:@"tabBarInfoActive"]
};
NSArray *tabImgArray = @[imgDict1, imgDict2, imgDict3];
带参数初始化
ZATabBarController *tabBarController = [[ZATabBarController alloc] initWithViewControllers:tabVCArray imageArray:tabImgArray];
初始化和设置参数
ZATabBarController *tabBarController = [[ZATabBarController alloc] init];
[tabBarController setViewControllers:tabVCArray imageArray:tabImgArray];
设置标签的宽度
tabBarController.tabBar.buttonItemWidth = 80.0f;
设置背景颜色
tabBarController.tabBar.backgroundView.backgroundColor = [UIColor blackColor];
设置选中颜色
tabBarController.tabBar.selectedColor = [UIColor greenColor];
设置标签缩进
tabBarController.tabBar.buttonInsets = UIEdgeInsetsMake(5, 2, 5, 2);
vc1.hidesBottomBarWhenPushed = YES; // like standart tabbar