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

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对应的代码

改动后:


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;
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容