- Supports iPad and iPhone
- Supports iphone X
- Supports landscape and portrait orientations
- Can be used inside UINavigationController
- Support the dynamic and static images of the selected and normal state
- Irregular Item
If you're using CocoaPods, simply add pod 'ZTTabBarController'
to your Podfile.
Add the items from ZTTabBarController
directory to your project. If you don't have ARC enabled, you will need to set a -fobjc-arc
compiler flag on the .m
source files.
The initialization is simple,just insert code below
ZTTabbarItemAttribute * attribute = [ZTTabbarItemAttribute defaultAttribute];
ZTTabbarController * tabbarController = [ZTTabbarController tabbarWithItemModels:[self models] itemAppearce:attribute];
[tabbarController setChildViewControllers:[self viewControllers]];
tabbarController.delegate = self;
tabbarController.rectEdge = UIRectEdgeNone;
self.window.rootViewController = tabbarController;
- (NSArray <ZTTabbarItemModel *> *)models {
ZTTabbarItemModel * model1 = [[ZTTabbarItemModel alloc]initWithNormalImageName:@"1_normal" andSelectImageName:@"1_select" andTitle:@"测试标题1"];
ZTTabbarItemModel * model2 = [[ZTTabbarItemModel alloc]initWithNormalImageName:@"2_normal" andSelectImageName:@"2_select" andTitle:@"测试标题2"];
ZTTabbarItemModel * model3 = [[ZTTabbarItemModel alloc]initWithNormalImageName:@"3_normal" andSelectImageName:@"3_select" andTitle:@"测试标题3"];
ZTTabbarItemModel * model4 = [[ZTTabbarItemModel alloc]initWithNormalImageName:@"4_normal" andSelectImageName:@"4_select" andTitle:@"测试标题4"];
return @[model1,model2,model3,model4];
}
- (NSArray <UIViewController *>*)viewControllers {
return @[[self navcWithVC:[ViewController1 new]],[self navcWithVC:[ViewController2 new]],[self navcWithVC:[ViewController3 new]],[self navcWithVC:[ViewController4 new]]];
}
- (UINavigationController *)navcWithVC:(UIViewController *)vc {
return [[UINavigationController alloc]initWithRootViewController:vc];
}
this class is design to change item behavior by user
@property (strong, nonatomic) UIColor *itemTitleColor;
@property (strong, nonatomic) UIColor *itemTitleSelectColor;
@property (strong, nonatomic) UIFont *itemTitleFont;
@property (strong, nonatomic) UIColor *itemBgColor;
@property (strong, nonatomic) UIColor *itemBgSelectColor;
@property (assign, nonatomic) CGSize itemImgSize;
- (void)ZTTabbarController:(ZTTabbarController *)tabbarController willChangeSelectIndex:(NSInteger)selectIndex;
- (void)ZTTabbarController:(ZTTabbarController *)tabbarController didChangeSelectIndex:(NSInteger)selectIndex;
- (BOOL)ZTTabbarController:(ZTTabbarController *)tabbarController shouldChangeSelectIndex:(NSInteger)selectIndex;
- ARC
- iOS 8.0 or later
- Xcode 7
ZTTabBarController is available under the MIT license. See the LICENSE file for more info.