pod 'RDVTabBarController'
建議直接CocoaPods管理,對CocoaPods有興趣的童鞋可以戳cocoapods-install-usage
RDVTabBar @interface RDVTabBar : UIView
RDVTabBarController@interface RDVTabBarController : UIViewController
RDVTabBarItem@interface RDVTabBarItem : UIControl
RDVTabBarController Example Usage其實已經(jīng)很詳細了,接下來看初始化
//VString宏定義,為了就是更好的國際化語言,適配多語言,剛好此Demo也國際化了,可以參看https://github.com/sauchye/dev_notes/issues/4 #define VString(x) NSLocalizedString(x, nil)
- (void)setupViewControllers{ SYFirstViewController *firstVC = [[SYFirstViewController alloc] init]; SYSecondViewController *secondVC = [[SYSecondViewController alloc] init]; SYThirdViewController *thirdVC = [[SYThirdViewController alloc] init]; firstVC.title = VString(@"Home"); secondVC.title = VString(@"Found"); thirdVC.title = VString(@"Me"); self.firstNav = [[SYBaseNavigationController alloc] initWithRootViewController:firstVC]; self.secondNav = [[SYBaseNavigationController alloc] initWithRootViewController:secondVC]; self.thirdNav = [[SYBaseNavigationController alloc] initWithRootViewController:thirdVC]; [self setViewControllers:@[self.firstNav, self.secondNav, self.thirdNav]]; [self customizeTabBarForController];}
- (void)customizeTabBarForController{ //tabbar 背景圖片 tabbar_background UIImage *backgroundImage = [UIImage imageNamed:@"tabbar_background"]; //選項卡圖片 NSArray *tabBarItemImages; //這里添加tabBar icon圖片 //= @[VString(@"First"), VString(@"Second"),VString(@"Third")]; NSArray *tabBarItemTitles = @[VString(@"Home"), VString(@"Found"), VString(@"Me")]; NSInteger index = 0; for (RDVTabBarItem *item in [[self tabBar] items]) { item.titlePositionAdjustment = UIOffsetMake(0, 2.0); [item setBackgroundSelectedImage:backgroundImage withUnselectedImage:backgroundImage]; UIImage *selectedimage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_selected",[tabBarItemImages objectAtIndex:index]]]; UIImage *unselectedimage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_normal",[tabBarItemImages objectAtIndex:index]]]; [item setFinishedSelectedImage:selectedimage withFinishedUnselectedImage:unselectedimage]; [item setTitle:[tabBarItemTitles objectAtIndex:index]]; item.selectedTitleAttributes = @{ NSFontAttributeName: [UIFont boldSystemFontOfSize:12], NSForegroundColorAttributeName:kNAVIGATION_BAR_COLOR, }; item.unselectedTitleAttributes = @{ NSFontAttributeName: [UIFont boldSystemFontOfSize:12], NSForegroundColorAttributeName:RGB(217, 217, 217), }; [item setTitle:[tabBarItemTitles objectAtIndex:index]]; index++; }}
objective-c - (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [[self rdv_tabBarController] setTabBarHidden:YES animated:YES]; }
objective-c [[self rdv_tabBarItem] setBadgeValue:@"3"];
``` objective-c
/**
/**
(void)tabBarController:(RDVTabBarController )tabBarController didSelectViewController:(UIViewController )viewController;
```
還有需要多等待你去發(fā)現(xiàn)...
RDVTabBarController是一個很棒的第三方tabBarController,值得我們學(xué)習(xí)和思考。
--
本文,由我們 iOS122 的小伙伴 @Sauchye?供稿,更多討論,參見: http://www.ios122.com/tag/rdvtabbarcontroller/
新聞熱點
疑難解答