侧划导航菜单
2016-04-21 23:54
330 查看
话不多说,先上图
![](http://static.oschina.net/uploads/space/2016/0421/231747_plMZ_2618362.png)
![](http://static.oschina.net/uploads/space/2016/0421/231747_NxnA_2618362.png)
具体代码实现:
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];
}
![](http://static.oschina.net/uploads/space/2016/0421/231747_plMZ_2618362.png)
![](http://static.oschina.net/uploads/space/2016/0421/231747_NxnA_2618362.png)
具体代码实现:
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];
}
相关文章推荐
- 20150119--无限级分类+商品分类 01
- mysql_query返回false原因
- Android学习笔记(41):File存储
- 弹出键盘时按钮自动上移
- Navicat for MySQL 工具注册码
- 前端笔记 CSS 5
- android中Activity中的WindowManager与Window
- Excel转PDF的相关问题处理
- 二维情形下的最接近点对问题
- 向量时钟Vector Clock in Riak
- 一个新奇的东西,调试布局利器
- Web系统架构分层
- 第9周学习进度表
- wewe
- Modern PHP读书笔记一
- Python爬虫笔记----爬虫技术入门(1)
- excel的导入导出
- 考研回忆录之时间效率
- iOS开发真机调试与App上架
- java Thread sleep yield join wait notify notifyAll