- (void)setupSubviews
{
self.tabBar.backgroundImage = [[UIImage imageNamed:@"tabbarBackground"] stretchableImageWithLeftCapWidth:25 topCapHeight:25];
self.tabBar.selectionIndicatorImage = [[UIImage imageNamed:@"tabbarSelectBg"] stretchableImageWithLeftCapWidth:25 topCapHeight:25];
_chatListVC = [[ChatListViewController alloc] init];
_chatListVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"会话"
image:nil
tag:0];
[_chatListVC.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"tabbar_chatsHL"]
withFinishedUnselectedImage:[UIImage imageNamed:@"tabbar_chats"]];
[self unSelectedTapTabBarItems:_chatListVC.tabBarItem];
[self selectedTapTabBarItems:_chatListVC.tabBarItem];
_contactsVC = [[ContactsViewController alloc] initWithNibName:nil bundle:nil];
_contactsVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"通讯录"
image:nil
tag:1];
[_contactsVC.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"tabbar_contactsHL"]
withFinishedUnselectedImage:[UIImage imageNamed:@"tabbar_contacts"]];
[self unSelectedTapTabBarItems:_contactsVC.tabBarItem];
[self selectedTapTabBarItems:_contactsVC.tabBarItem];
_settingsVC = [[SettingsViewController alloc] init];
_settingsVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"设置"
image:nil
tag:2];
[_settingsVC.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"tabbar_settingHL"]
withFinishedUnselectedImage:[UIImage imageNamed:@"tabbar_setting"]];
_settingsVC.view.autoresizingMask = UIViewAutoresizingFlexibleHeight;
[self unSelectedTapTabBarItems:_settingsVC.tabBarItem];
[self selectedTapTabBarItems:_settingsVC.tabBarItem];
self.viewControllers = @[_chatListVC, _contactsVC, _settingsVC];
[self selectedTapTabBarItems:_chatListVC.tabBarItem];
}
-(void)unSelectedTapTabBarItems:(UITabBarItem *)tabBarItem
{
[tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont systemFontOfSize:14], UITextAttributeFont,[UIColor whiteColor],UITextAttributeTextColor,
nil] forState:UIControlStateNormal];
}
-(void)selectedTapTabBarItems:(UITabBarItem *)tabBarItem
{
[tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont systemFontOfSize:14],
UITextAttributeFont,[UIColor colorWithRed:0.393 green:0.553 blue:1.000 alpha:1.000],UITextAttributeTextColor,
nil] forState:UIControlStateSelected];
}