Simple use of the Mmdrawercontroller drawer side bar

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.