您可以使用MMDrawcontroller并通过 Navigationcontroller 传递 LeftView、RightView 和 Centerview。所有三个控制器都是UIViewController
. 您还可以使用与 CenterView 相同的 NavigationController 添加左视图和右视图,以便您可以从左视图和右视图推送。
CenterVC *objCenter = [[CenterVC alloc] initWithNibName:@"CenterVC" bundle:nil];
LeftVC *objleftVC = [[LeftVC alloc] initWithNibName:@"LeftVC" bundle:nil];
RightVC *objrightVC = [[RightVC alloc] initWithNibName:@"RightVC" bundle:nil];
/*--- Init navigation for Center Controller ---*/
UINavigationController *_navC = [[UINavigationController alloc] initWithRootViewController:objCenter];
_navC.navigationBarHidden = YES;
_navC.navigationBar.translucent = NO;
MMDrawerController *drawerController = [[MMDrawerController alloc]
initWithCenterViewController:_navC
leftDrawerViewController:objleftVC
rightDrawerViewController:objrightVC];
[drawerController setShowsShadow:NO];
[drawerController setRestorationIdentifier:@"MMDrawer"];
[drawerController setMaximumLeftDrawerWidth:[[UIScreen mainScreen] bounds].size.width-45.0];
[drawerController setMaximumRightDrawerWidth:[[UIScreen mainScreen] bounds].size.width-45.0];
[drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
[drawerController setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];
[drawerController setShouldStretchDrawer:NO];
[drawerController
setDrawerVisualStateBlock:^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) {
MMDrawerControllerDrawerVisualStateBlock block;
block = [[MMExampleDrawerVisualStateManager sharedManager]
drawerVisualStateBlockForDrawerSide:drawerSide];
if(block){
block(drawerController, drawerSide, percentVisible);
}
}];
[self.navigationController pushViewController:drawerController animated:isAnimate];
使用Storyboard下载(https://github.com/TomSwift/MMDrawerController-Storyboard)。添加MMDrawerController+Storyboard
然后替换或检查上面演示中使用的故事板,并根据演示在 AppDelegate 中添加代码。
所以您的演示项目将如下图所示
