chenliangloveyou/EasyShowView

在tabbar+nav的界面中,tabbar文字不显示

Kienty opened this issue · 0 comments

-(void)initTabBarController
{
// self.delegate = self;

UIViewController *homeVC = [[UIViewController alloc] init];
homeVC.title = @"测试1";
EasyNavigationController *homeNag = [self settingTabbarItemWithRootVC:homeVC img:@"tab_home_note" selectImg:@"tab_home_selected"];

UIViewController *discoveryVC = [[UIViewController alloc] init];
discoveryVC.title = @"测试2";
EasyNavigationController *workProNag = [self settingTabbarItemWithRootVC:discoveryVC img:@"tab_dynamic_note" selectImg:@"tab_dynamic_selected"];

UIViewController *orderVC = [[UIViewController alloc] init];
orderVC.title = @"测试3";
EasyNavigationController *processNag = [self settingTabbarItemWithRootVC:orderVC img:@"tab_chat_note" selectImg:@"tab_chat_selected"];

UIViewController *mineVC = [[UIViewController alloc] init];
mineVC.title = @"测试4";
EasyNavigationController *mineNav = [self settingTabbarItemWithRootVC:mineVC img:@"tab_mine_note" selectImg:@"tab_home_selected"];
//workProNag
self.viewControllers = @[homeNag,workProNag,processNag,mineNav];
self.selectedIndex = 0;

}

  • (EasyNavigationController *)settingTabbarItemWithRootVC:(id)VC img:(NSString *)imgStr selectImg:(NSString *)selectImg
    {
    EasyNavigationController *nag = [[EasyNavigationController alloc] initWithRootViewController:VC];
    [nag.tabBarItem setImage:[[UIImage imageNamed:imgStr] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    [nag.tabBarItem setSelectedImage:[[UIImage imageNamed:selectImg] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    [nag.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObject:[UIColor blackColor] forKey:NSForegroundColorAttributeName] forState:UIControlStateNormal];
    [nag.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObject:[UIColor blackColor] forKey:NSForegroundColorAttributeName] forState:UIControlStateSelected];
    return nag;
    }

WeChat0f25a02cce1ad96603639ba7696ba786