MMDrawerController(第三方类库)侧边栏的使用

MMDrawerController是一个小巧简单方便的第三方类库,可以实现简单的侧边栏功能。

使用方式:

1.通过cocopad加入类库或者到github上下载。

2.在appdelegate中导入头文件:#import "MMDrawerController.h"

3.初始化左右和中心三个视图;

 _leftController = [[LeftTableViewController alloc]init];
 _rightController = [[RightViewController alloc]init];
UIStoryboard *mainStory = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

 

 

4.将三个视图添加到MMDrawerController上,只需要调用一个方法就能够实现,很简单

 _mmDrawer = [[MMDrawerController alloc]initWithCenterViewController:[mainStory instantiateViewControllerWithIdentifier:@"center"] leftDrawerViewController:_leftController rightDrawerViewController:_rightController];

5.设置左右侧边栏的宽度:

 [_mmDrawer setMaximumLeftDrawerWidth:200.0];
[_mmDrawer setMaximumRightDrawerWidth:
200.0];

6.添加侧边栏手势

 [_mmDrawer setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
 [_mmDrawer setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];

7.将MMDrawerController设置为根视图

self.window.rootViewController = _mmDrawer;

8.在中心视图添加打开关闭侧边栏按钮

 AppDelegate *delegate = [UIApplication sharedApplication].delegate;
[
delegate.mmDrawer toggleDrawerSide:MMDrawerSideLeft animated:YES completion:nil];//左侧打开关闭侧边栏方法

 

posted @ 2015-11-10 15:32  墨VS雪  阅读(1495)  评论(0编辑  收藏  举报