tabbaritem点击状态 字体颜色仍然是系统蓝

-(void) initTabbar

{

         _HomeVC = [[NewHomeViewController alloc] init];

       {

        UIImage *localNormal = [[UIImage iconWithInfo:TBCityIconInfoMake(@"\U0000e926 ",       20, [HqewUtil colorWithHexString:@"#93a2ae"])]  imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

       UIImage *localSelect = [[UIImage iconWithInfo:TBCityIconInfoMake(@"\U0000e925 ", 20, [HqewUtil colorWithHexString:@"#3762ad"])] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

      _HomeVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"首页" image:localNormal selectedImage:localSelect];

}

SGLNavigationViewController *homeNaviCtrl = [[SGLNavigationViewController alloc] initWithRootViewController:_HomeVC];

_AddressVC = [[AddressBookViewController alloc] init];

_AddressVC.title = @"会员";

{

UIImage *onlineNormal = [[UIImage imageNamed:@"AddressBookMember-UnSelect.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

UIImage *onlineSelect = [[UIImage imageNamed:@"newAdressBookMemberSelect.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

_AddressVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"会员" image:onlineNormal selectedImage:onlineSelect];

}

SGLNavigationViewController *addressNaviCtrl = [[SGLNavigationViewController alloc] initWithRootViewController:_AddressVC];

// 消息

_manageVC = [[NewManagerViewController alloc] init];

_manageVC.title=@"管理";

{

UIImage *localNormal = [[UIImage iconWithInfo:TBCityIconInfoMake(@"\U0000e90e ", 20, [ HqewUtil colorWithHexString:@"#93a2ae"])] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

UIImage *localSelect = [[UIImage iconWithInfo:TBCityIconInfoMake(@"\U0000e90d ", 20, [HqewUtil colorWithHexString:@"#3762ad"])] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

_manageVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"管理" image:localNormal selectedImage:localSelect];

}

SGLNavigationViewController *messageListNaviCtrl = [[SGLNavigationViewController alloc] initWithRootViewController:_manageVC];

//    UINavigationController *messageListNaviCtrl = [[UINavigationController alloc] initWithRootViewController:_manageVC];

_PerSonCenterVC = [[NewPersonViewController alloc] init];

_PerSonCenterVC.title = @"我的";

{

UIImage *cartNormal = [[UIImage iconWithInfo:TBCityIconInfoMake(@"\U0000e92d ", 20, [ HqewUtil colorWithHexString:@"#93a2ae"])] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

//        UIImage *cartSelect = [[UIImage iconWithInfo:TBCityIconInfoMake(@"\U0000e92d ", 20, [HqewUtil colorWithHexString:@"#3762ad"])] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

UIImage *cartSelect = [[UIImage imageNamed:@"005782A5-EB25-44BB-A5E1-B2BB7C129B3E.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

_PerSonCenterVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"我的" image:cartNormal selectedImage:cartSelect];

}

SGLNavigationViewController *personNaviCtrl = [[SGLNavigationViewController alloc] initWithRootViewController:_PerSonCenterVC];

_PublishVC = [[PublishViewController alloc] init];

_PublishVC.title = @"发布";

{

//  [UIImage imageNamed:@""]  替换[UIImage iconWithInfo:TBCityIconInfoMake(@"\U0000e907 ", 20, [UIColor blueColor])]

UIImage *cartNormal = [[UIImage iconWithInfo:TBCityIconInfoMake(@"\U0000e906 ", 20, [ HqewUtil colorWithHexString:@"#93a2ae"])] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

UIImage *cartSelect = [[UIImage iconWithInfo:TBCityIconInfoMake(@"\U0000e905 ", 20, [HqewUtil colorWithHexString:@"#50acee"])] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

_PublishVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"发布" image:cartNormal selectedImage:cartSelect];

}

SGLNavigationViewController *sendNeedNaviCtrl = [[SGLNavigationViewController alloc] initWithRootViewController:_PublishVC];

//设置tabbaritem字体点击效果

NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];

textAttrs[NSForegroundColorAttributeName] =[ HqewUtil colorWithHexString:@"#999999"];

textAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];

NSMutableDictionary *selectTextAttrs = [NSMutableDictionary dictionary];

selectTextAttrs[NSForegroundColorAttributeName] = [HqewUtil colorWithHexString:@"#2251a5"];

selectTextAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];

/***/

[homeNaviCtrl.tabBarItem setTitleTextAttributes:textAttrs forState:UIControlStateNormal];

[homeNaviCtrl.tabBarItem setTitleTextAttributes:selectTextAttrs forState:UIControlStateSelected];

[addressNaviCtrl.tabBarItem setTitleTextAttributes:textAttrs forState:UIControlStateNormal];

[addressNaviCtrl.tabBarItem setTitleTextAttributes:selectTextAttrs forState:UIControlStateSelected];

[messageListNaviCtrl.tabBarItem setTitleTextAttributes:textAttrs forState:UIControlStateNormal];

[messageListNaviCtrl.tabBarItem setTitleTextAttributes:selectTextAttrs forState:UIControlStateSelected];

[personNaviCtrl.tabBarItem setTitleTextAttributes:textAttrs forState:UIControlStateNormal];

[personNaviCtrl.tabBarItem setTitleTextAttributes:selectTextAttrs forState:UIControlStateSelected];

//判断并设置自定义的tabbar

NSMutableArray *navArray = [[NSMutableArray alloc]initWithCapacity:0];

[navArray addObject:homeNaviCtrl];

[navArray addObject:addressNaviCtrl];

//    [navArray addObject:sendNeedNaviCtrl];

[navArray addObject:messageListNaviCtrl];

[navArray addObject:personNaviCtrl];

_tabbarController = [[UITabBarController alloc] init];

//  设置tabbarController要显示viewController们。

_tabbarController .viewControllers=navArray;

self.window.rootViewController = _tabbarController;

}




要把设置字体点击未点击方法写在tabbarcontroller成为根视图控制器之前

tabbar 设置选中文字的颜色

你可能感兴趣的:(tabbaritem点击状态 字体颜色仍然是系统蓝)