MMDrawerController(第三方类库)侧边栏的使用
生活随笔
收集整理的這篇文章主要介紹了
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];//左側打開關閉側邊欄方法
?
轉載于:https://www.cnblogs.com/moxuexiaotong/p/4953219.html
總結
以上是生活随笔為你收集整理的MMDrawerController(第三方类库)侧边栏的使用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: sublime text3输入中文的问题
- 下一篇: hdu2036(多边形面积)