美文网首页iOS Developer
在使用UITabBar来结合NavgationControlle

在使用UITabBar来结合NavgationControlle

作者: 灰客 | 来源:发表于2017-04-25 17:48 被阅读0次
    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;
    

    相关文章

      网友评论

        本文标题:在使用UITabBar来结合NavgationControlle

        本文链接:https://www.haomeiwen.com/subject/rtavzttx.html