tabBar工具条框架 (适应各种APP风格,集成只需几行代码,没有耦合度)
jopen
9年前
XZMTabbarExtension
tabBar工具条框架 (适应各种APP风格,集成只需几行代码,没有耦合度)
动态工具条
/** 创建自定义tabbar */ XZMTabbarExtension *tabBar = [[XZMTabbarExtension alloc] init]; tabBar.backgroundColor = [UIColor whiteColor]; tabBar.frame = self.tabBar.bounds; /** 传递模型数组 */ tabBar.items = self.itemArray; [tabBar xzm_setShadeItemBackgroundColor:[UIColor cyanColor]]; /** 设置代理 */ tabBar.delegate = self; [self.tabBar addSubview:tabBar]; /** 代理方法 */ - (void)xzm_tabBar:(XZMTabbarExtension *)tabBar didSelectItem:(NSInteger)index{ self.selectedIndex = index; }
个性化中间按钮
- 使用框架的UITabBar扩展方法即可
/** 配置中间按钮 */ [self.tabBar setUpTabBarCenterButton:^(UIButton *centerButton) { [centerButton setBackgroundImage:[UIImage imageNamed:@"tabBar_publish_icon"] forState:UIControlStateNormal]; [centerButton setBackgroundImage:[UIImage imageNamed:@"tabBar_publish_click_icon"] forState:UIControlStateSelected]; [centerButton addTarget:self action:@selector(chickCenterButton) forControlEvents:UIControlEventTouchUpInside]; }]; - (void)chickCenterButton { NSLog(@"点击了中间按钮"); [self presentViewController:[[XZMPublishViewController alloc] init] animated:NO completion:nil]; }