在使用UITabBar来结合NavgationController来写框架,我的nav被一个白色的视图控制器的title挡住了

在使用UITabBar来结合NavgationController来写框架,我的nav被一个白色的视图控制器的title挡住了_第1张图片
DDF07DB8-30DD-4CCB-AAD5-F4F4A53F7E3B.png

我的nav本来设置的红色,但是被前面这个遮住了
DJMYViewController * business = [[DJMYViewController alloc] init];
business.title = @"我";
UINavigationController * nav3 = [[UINavigationController alloc] initWithRootViewController:business];
[self setViewControllers:@[nav1,nav2,nav3]];

这是在我的UITabBarController里面写的3个nav对应的代码

改动后:


在使用UITabBar来结合NavgationController来写框架,我的nav被一个白色的视图控制器的title挡住了_第2张图片
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;

你可能感兴趣的:(在使用UITabBar来结合NavgationController来写框架,我的nav被一个白色的视图控制器的title挡住了)