1 需要导入的头文件
#import "MMDrawerController.h"
这个插件主要在APPdelegate 中操作 原因是 你需要设置 MMDrawerController类 的对象作为根视图
typedef NS_ENUM(NSInteger,MMDrawerSide){
MMDrawerSideNone = 0,
MMDrawerSideLeft,
MMDrawerSideRight,
};
typedef NS_OPTIONS(NSInteger, MMOpenDrawerGestureMode) {
MMOpenDrawerGestureModeNone = 0,
MMOpenDrawerGestureModePanningNavigationBar = 1 << 1,
MMOpenDrawerGestureModePanningCenterView = 1 << 2,
MMOpenDrawerGestureModeBezelPanningCenterView = 1 << 3,
MMOpenDrawerGestureModeCustom = 1 << 4,
MMOpenDrawerGestureModeAll = MMOpenDrawerGestureModePanningNavigationBar |
MMOpenDrawerGestureModePanningCenterView |
MMOpenDrawerGestureModeBezelPanningCenterView |
MMOpenDrawerGestureModeCustom,
};
UIViewController * leftSideDrawerViewController = [[MMExampleLeftSideDrawerViewController alloc] init];
UIViewController * centerViewController = [[MMExampleCenterTableViewController alloc] init];
UIViewController * rightSideDrawerViewController = [[MMExampleRightSideDrawerViewController alloc] init];
UINavigationController * navigationController = [[MMNavigationController alloc] initWithRootViewController:centerViewController]; // 中心控制器
右控制器
UINavigationController * rightSideNavController = [[MMNavigationController alloc] initWithRootViewController:rightSideDrawerViewController];
左控制器
UINavigationController * leftSideNavController = [[MMNavigationController alloc] initWithRootViewController:leftSideDrawerViewController];
集成控制器操作
self.drawerController = [[MMDrawerController alloc]
initWithCenterViewController:navigationController
leftDrawerViewController:leftSideNavController
rightDrawerViewController:rightSideNavController];
[self.drawerController setShowsShadow:NO];
右控制器的初始宽度
[self.drawerController setMaximumRightDrawerWidth:200.0];
打开的手势操作区域
typedef NS_OPTIONS(NSInteger, MMOpenDrawerGestureMode) {
MMOpenDrawerGestureModeNone = 0,
MMOpenDrawerGestureModePanningNavigationBar = 1 << 1,
MMOpenDrawerGestureModePanningCenterView = 1 << 2,
MMOpenDrawerGestureModeBezelPanningCenterView = 1 << 3,
MMOpenDrawerGestureModeCustom = 1 << 4,
MMOpenDrawerGestureModeAll
[self.drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
关闭的手势操作区域
typedef NS_OPTIONS(NSInteger, MMCloseDrawerGestureMode) {
MMCloseDrawerGestureModeNone = 0,
MMCloseDrawerGestureModePanningNavigationBar = 1 << 1,
MMCloseDrawerGestureModePanningCenterView = 1 << 2,
MMCloseDrawerGestureModeBezelPanningCenterView = 1 << 3,
MMCloseDrawerGestureModeTapNavigationBar = 1 << 4,
MMCloseDrawerGestureModeTapCenterView = 1 << 5,
MMCloseDrawerGestureModePanningDrawerView = 1 << 6,
MMCloseDrawerGestureModeCustom = 1 << 7,
MMCloseDrawerGestureModeAll = MMCloseDrawerGestureModePanningNavigationBar |
MMCloseDrawerGestureModePanningCenterView |
MMCloseDrawerGestureModeBezelPanningCenterView |
MMCloseDrawerGestureModeTapNavigationBar |
MMCloseDrawerGestureModeTapCenterView |
MMCloseDrawerGestureModePanningDrawerView |
MMCloseDrawerGestureModeCustom,
};
[self.drawerController setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];
把对象作为根视图
[self.window setRootViewController:self.drawerController];
好了 在APPDelegate 中已经设置好了 这时 你的模拟器也能显示出来效果了 但是你如果想在点击按钮的时候操作 还需要设置这个方法
增加文件夹
#import “UIViewController+MMDrawerController.h” // 这是一个扩展类
typedef NS_ENUM(NSInteger,MMDrawerSide){
MMDrawerSideNone = 0,
MMDrawerSideLeft,
MMDrawerSideRight,
};
[mmDraw openDrawerSide:MMDrawerSideLeft animated:YES completion:nil];