RDVTabBarController:一个十分完善的tabBarController,可以自定义角标个数,爽的停不下来。
RDVTabBarController地址:RDVTabBarController
Demo地址:欢迎Star
[[self rdv_tabBarItem] setBadgeValue:@"3"];
/**
* Asks the delegate whether the specified view controller should be made active.
*/
- (BOOL)tabBarController:(RDVTabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController;
/**
* Tells the delegate that the user selected an item in the tab bar.
*/
- (void)tabBarController:(RDVTabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController;
- (void)customizeTabBarForController{ //tabbar 背景图片 tabbar_background UIImage *backgroundImage = [UIImage imageNamed:@"tabbar_background"]; //选项卡图片 NSArray *tabBarItemImages; //这里添加tabBar icon图片 //= @[VString(@"First"), VString(@"Second"),VString(@"Third")]; NSArray *tabBarItemTitles = @[@"Home", @"Found", @"Me"]; NSInteger index = 0; for (RDVTabBarItem *item in [[self tabBar] items]) { //tabbarItem位置设置 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++; } }
4.VString宏定义,为了就是更好的国际化语言,适配多语言,刚好此Demo也国际化了
#define VString(x) NSLocalizedString(x, nil)