您的位置:首页 > 其它

侧划导航菜单

2016-04-21 23:54 330 查看
话不多说,先上图





具体代码实现:

1,在AppDelegate中:

#import "AppDelegate.h"
#import "MMDrawerController.h"
#import "ViewController.h"
#import "LeftViewController.h"
@interface AppDelegate ()

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

_window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
ViewController *centerVC = [[ViewController alloc]init];
UINavigationController *centerNav = [[UINavigationController alloc]initWithRootViewController:centerVC];
LeftViewController *leftVc = [[LeftViewController alloc]init];

MMDrawerController *rootVc = [[MMDrawerController alloc]initWithCenterViewController:centerNav leftDrawerViewController:leftVc];
[rootVc setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
[rootVc setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];
_window.rootViewController = rootVc;
[_window makeKeyAndVisible];
return YES;
}
2,在ViewController中:

#import "ViewController.h"
#import "MMDrawerController.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(leftAction)];

self.view.backgroundColor = [UIColor redColor];

}
-(void)leftAction{
MMDrawerController *drawVc = (MMDrawerController *)[UIApplication sharedApplication].keyWindow.rootViewController;
[drawVc toggleDrawerSide:MMDrawerSideLeft animated:YES completion:nil];

}

3,创建LeftViewController

#import "LeftViewController.h"

@interface LeftViewController ()

@end

@implementation LeftViewController

- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor yellowColor];
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: