1.MMDrawerController is a simple and practical side bar third-party class library.
2. In the Appdelegate page, initialize the left right sidebar you need, Leftviewcontroller, Mainviewcontroller.
3. Import the header file #import "MMDrawerController.h" in Appdelegate
4. Initialize the drawer controller:
Mmdrawercontroller * Drawercontroller = [[Mmdrawercontroller alloc] Initwithcenterviewcontroller: Mainviewcontrollerleftdrawerviewcontroller:leftviewcontroller];
5. Set some properties of the drawer
Set the width of the left drawer for extraction
Drawercontroller.maximumleftdrawerwidth = 200;
Set Drawer view VC Shadow Effect
Self.mmDrawController.showsShadow = YES;
6. Add a swipe gesture to pull and retract the drawer with a swipe gesture.
[Drawercontroller Setopendrawergesturemodemask:mmopendrawergesturemodeall];
[Drawercontroller Setclosedrawergesturemodemask:mmclosedrawergesturemodeall];
7. Add a button to the center view
1) Add header file in Center view
#import "Uiviewcontroller+mmdrawercontroller.h"//third-party encapsulated header files
#import "MMDrawerBarButtonItem.h"//third-party encapsulated header files
#import "LeftDrawerTableViewController.h", and left view header file
2) How to create a button
-(void) Setupleftmenubutton
{
Create button
Mmdrawerbarbuttonitem * Leftdrawerbutton = [[Mmdrawerbarbuttonitem alloc] initwithtarget:self action: @selector ( Leftdrawerbuttonpress:)];
Add Leftbarbuttonitem for Navigationitem
[Self.navigationitem Setleftbarbuttonitem:leftdrawerbutton Animated:yes];
}
3) Action to add a button
Drawer button Action
-(void) leftdrawerbuttonpress: (ID) sender
{
Switch left drawer
[Self.mm_drawercontroller toggledrawerside:mmdrawersideleft Animated:yes Completion:nil];
}
Simple use of the Mmdrawercontroller drawer side bar