美文网首页
关于UINavigationController、Tabbar

关于UINavigationController、Tabbar

作者: wanmei世界 | 来源:发表于2017-10-19 10:05 被阅读80次

    Tabbar

    1. 首页显示tabbar,push其他页面后隐藏tabbar
    ToViewController.hidesBottomBarWhenPushed=YES;
    

    presentViewController时隐藏tabbar

    UIViewController *presentedVC = [[UIViewController alloc]init];
    
    presentedVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;
    
    AppDelegate *appdelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
    
    appdelegate.window.rootViewController.definesPresentationContext = YES;
    
    [appdelegate.window.rootViewController presentViewController:presentedVC  animated:YES completion:nil];
    

    UINavigationController

    1. 根控制器隐藏NavigationBar,其他页面不隐藏或者部分隐藏NavigationBar
    #pragma mark --- UINavigationControllerDelegate
    - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
        if (![viewController isKindOfClass:[self class]]) {
            [navigationController setNavigationBarHidden:NO animated:animated];
        }
    }
    
    - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
        if ([viewController isKindOfClass:[self class]]) {
            [navigationController setNavigationBarHidden:YES animated:animated];
        }
    }
    

    相关文章

      网友评论

          本文标题:关于UINavigationController、Tabbar

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