我的nav本来设置的红色,但是被前面这个遮住了
DJMYViewController * business = [[DJMYViewController alloc] init];
business.title = @"我";
UINavigationController * nav3 = [[UINavigationController alloc] initWithRootViewController:business];
[self setViewControllers:@[nav1,nav2,nav3]];
这是在我的UITabBarController里面写的3个nav对应的代码
改动后:
E5F9DD94-24B6-4016-97E9-0539FC746AEA.png
代码如下:
DJConferenceViewController * staffVC = [[DJConferenceViewController alloc] init];
UINavigationController * nav1 = [[UINavigationController alloc] initWithRootViewController:staffVC];
nav1.tabBarItem.title = @"大会";
[nav1.tabBarItem setImage:[[UIImage imageNamed:@"tab_title_Dahui30-1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[nav1.tabBarItem setSelectedImage:[[UIImage imageNamed:@"tab_title_dahui30"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
nav1.navigationBar.barTintColor = [UIColor redColor];
nav1.hidesBottomBarWhenPushed = YES;
在每个nav管理的对应的那个UIViewController里面去做nav的title按钮等设置:
代码如下:
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,0, 200, 44)];
titleLabel.backgroundColor = [UIColor clearColor];
titleLabel.font = [UIFont boldSystemFontOfSize:flexibleWidth(18.0f)];
titleLabel.textColor = [UIColor whiteColor];
titleLabel.textAlignment = NSTextAlignmentCenter;
titleLabel.text = @"大会";
self.navigationItem.titleView = titleLabel;
网友评论