Created
November 10, 2016 13:52
-
-
Save songxing10000/35a7167f6946f62e5c7afb44456c87fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define kClassKey @"rootVCClassString" | |
#define kTitleKey @"title" | |
#define kImgKey @"imageName" | |
#define kSelImgKey @"selectedImageName" | |
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
self.edgesForExtendedLayout = UIRectEdgeNone; | |
NSArray *childItemsArray = @[ | |
@{kClassKey : @"ConversationListController", | |
kTitleKey : @"聊天", | |
kImgKey : @"聊天未选中", | |
kSelImgKey : @"聊天选中"}, | |
@{kClassKey : @"ContactListViewController", | |
kTitleKey : @"通讯录", | |
kImgKey : @"通讯录未选中", | |
kSelImgKey : @"通讯录选中"}, | |
#if 0// 是否显示游戏 | |
@{kClassKey : @"BSGameVC", | |
kTitleKey : @"游戏", | |
kImgKey : @"游戏未选中", | |
kSelImgKey : @"游戏选中"}, | |
#else | |
@{kClassKey : @"BSFriendQuanVC", | |
kTitleKey : @"朋友圈", | |
kImgKey : @"朋友圈未选中", | |
kSelImgKey : @"朋友圈选中"}, | |
#endif | |
@{kClassKey : @"BSMineTVC", | |
kTitleKey : @"我的", | |
kImgKey : @"我的未选中", | |
kSelImgKey : @"我的选中"} ]; | |
[childItemsArray enumerateObjectsUsingBlock:^(NSDictionary *dict, NSUInteger idx, BOOL *stop) { | |
UIViewController *vc = [NSClassFromString(dict[kClassKey]) new]; | |
if (idx == 0) { | |
vc = [[ConversationListController alloc] initWithStyle:UITableViewStylePlain]; | |
} | |
vc.title = dict[kTitleKey]; | |
vc.tabBarItem.title = vc.title; | |
BSNavigationController *nav = [[BSNavigationController alloc] initWithRootViewController:vc]; | |
UITabBarItem *item = nav.tabBarItem; | |
item.title = dict[kTitleKey]; | |
item.image = [UIImage imageNamed:dict[kImgKey]]; | |
item.selectedImage = [[UIImage imageNamed:dict[kSelImgKey]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; | |
[item setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor mainColor]} forState:UIControlStateSelected]; | |
// [item setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor blackColor]} forState:UIControlStateNormal]; | |
[self addChildViewController:nav]; | |
}]; | |
self.selectedIndex = 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment