tabbaritem點(diǎn)擊狀態(tài) 字體顏色仍然是系統(tǒng)藍(lán)

-(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 = @"發(fā)布";

{

//? [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:@"發(fā)布" image:cartNormal selectedImage:cartSelect];

}

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

//設(shè)置tabbaritem字體點(diǎn)擊效果

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];

//判斷并設(shè)置自定義的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];

//? 設(shè)置tabbarController要顯示viewController們。

_tabbarController .viewControllers=navArray;

self.window.rootViewController = _tabbarController;

}




要把設(shè)置字體點(diǎn)擊未點(diǎn)擊方法寫在tabbarcontroller成為根視圖控制器之前

tabbar 設(shè)置選中文字的顏色

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容