side menu

2018-05-23  本文已影响4人  William_

使用 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;
    
}
上一篇下一篇

猜你喜欢

热点阅读