side menu

作者: William_ | 来源:发表于2018-05-23 15:54 被阅读4次

    使用 ViewDeck
    引入#import <ViewDeck/ViewDeck.h>
    需要将IIViewDeckController设置为rootViewcontroller

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        //tabbarController
        self.tabbar = [[HCXTabBarController alloc] init];
        //侧边栏
        HCXLeftMenuController *leftMenu = [[HCXLeftMenuController alloc] init];
        HCXNavController *leftNav = [[HCXNavController alloc] initWithRootViewController:leftMenu];
        
        IIViewDeckController *viewDeckController = [[IIViewDeckController alloc] initWithCenterViewController:self.tabbar leftViewController:leftNav];
        self.window.rootViewController = viewDeckController;
        
        self.window.backgroundColor = [UIColor whiteColor];
        [self.window makeKeyAndVisible];
        
        return YES;
    }
    
    
    

    在leftVC实现

    需要展示的区域
    self.preferredContentSize = CGSizeMake(kWindowW * 2 / 3, kWindowH);
    

    跳转也页面时需要获取到tabbar当前选中的controller

      HCXNavController *navCtr = ((AppDelegate *)[[UIApplication sharedApplication] delegate]).tabbar.selectedViewController;
      HCXLeftFirstController *vc = [[HCXLeftFirstController alloc] init];
      [navCtr pushViewController:vc animated:YES];
    

    设置显示隐藏navigationBar

    - (void)viewWillAppear:(BOOL)animated {
        
        [super viewWillAppear:animated];
        self.navigationController.navigationBar.hidden = YES;
        
    }
    
    - (void)viewDidDisappear:(BOOL)animated {
        
        [super viewDidDisappear:animated];
        self.navigationController.navigationBar.hidden = NO;
        
    }
    

    相关文章

      网友评论

          本文标题:side menu

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