首页 > 代码库 > xcode6 自定义UITabbarController
xcode6 自定义UITabbarController
-(void)initTabBarView{ if (tabBarController && [kAPPDELEGATE.navigationController.viewControllers containsObject:tabBarController]) { [kAPPDELEGATE.navigationController popToViewController:tabBarController animated:YES]; return; } [kAPPDELEGATE.navigationController popToRootViewControllerAnimated:NO]; [[UIApplication sharedApplication] setStatusBarHidden:NO]; NSMutableArray *controllers = [NSMutableArray array]; //UIImageRenderingModeAlwaysOriginal 图片按照原样渲染。 { SchoolSecondHandViewController *vc = [[SchoolSecondHandViewController alloc] initWithNibName:nil bundle:nil]; UITabBarItem *item = [[UITabBarItem alloc] initWithTitle: @"首页" image:[[UIImage imageNamed:@"tabbar_home"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tabbar_home_press"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]]; [item setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor redColor], NSForegroundColorAttributeName, nil] forState:UIControlStateHighlighted]; vc.tabBarItem = item; [controllers addObject:vc]; } { CollectSomeThingViewController *vc = [[CollectSomeThingViewController alloc] initWithNibName:nil bundle:nil]; UITabBarItem *item = [[UITabBarItem alloc] initWithTitle: @"首页" image:[[UIImage imageNamed:@"tabbar_home"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tabbar_home_press"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]]; [item setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor redColor], NSForegroundColorAttributeName, nil] forState:UIControlStateHighlighted]; vc.tabBarItem = item; [controllers addObject:vc]; } { LossSomeThingViewController *vc = [[LossSomeThingViewController alloc] initWithNibName:nil bundle:nil]; UITabBarItem *item = [[UITabBarItem alloc] initWithTitle: @"首页" image:[[UIImage imageNamed:@"tabbar_home"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tabbar_home_press"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]]; [item setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor redColor], NSForegroundColorAttributeName, nil] forState:UIControlStateHighlighted]; vc.tabBarItem = item; [controllers addObject:vc]; } { MoreViewController *vc = [[MoreViewController alloc] initWithNibName:nil bundle:nil]; UITabBarItem *item = [[UITabBarItem alloc] initWithTitle: @"首页" image:[[UIImage imageNamed:@"tabbar_home"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tabbar_home_press"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]]; [item setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor redColor], NSForegroundColorAttributeName, nil] forState:UIControlStateHighlighted]; vc.tabBarItem = item; [controllers addObject:vc]; } tabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil]; tabBarController.delegate = self; tabBarController.tabBar.clipsToBounds = TRUE; { tabBarController.tabBar.tintColor = kDEFAULT_BG_COLOR; [[UITabBar appearance] setBackgroundImage:[ZQUtiles imageWithColor:kDEFAULT_BG_COLOR size:CGSizeMake(29, 1)]];//设置背景,修改颜色是没有用的 [[UITabBar appearance] setSelectionIndicatorImage:[ZQUtiles imageWithColor:kDEFAULT_BG_COLOR size:CGSizeMake(29, 1)]]; } [tabBarController setViewControllers:controllers]; [kAPPDELEGATE.navigationController pushViewController:tabBarController animated:YES];}
xcode6 自定义UITabbarController
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。