使用起来还是比较简单的, 主要是几个步骤

AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = PP_AUTORELEASE([[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]); // 创建抽屉的根控制器
ViewController *main = [[ViewController alloc] init];
main.view.backgroundColor = [UIColor whiteColor];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:main]; // 创建抽屉控制器并且设置其根控制器
self.revealSideViewController = [[PPRevealSideViewController alloc] initWithRootViewController:nav]; self.revealSideViewController.delegate = self; // 将抽屉控制器作为根控制器
self.window.rootViewController = self.revealSideViewController; // 设置状态栏颜色
self.revealSideViewController.fakeiOS7StatusBarColor = [UIColor orangeColor]; self.window.backgroundColor = [UIColor whiteColor]; return YES;
}

ViewController.m

#import "ViewController.h"
#import "PPRevealSideViewController.h"
#import "RPOneViewController.h"
#import "RPTwoTableViewController.h" #define RPOffset 100 // 设置主控制器移动后留下的视图宽度 @interface ViewController () @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad]; UIBarButtonItem *left = [[UIBarButtonItem alloc] initWithTitle:@"Left"
style:UIBarButtonItemStylePlain
target:self
action:@selector(showLeft)];
self.navigationItem.leftBarButtonItem = left; UIBarButtonItem *right = [[UIBarButtonItem alloc] initWithTitle:@"Right"
style:UIBarButtonItemStylePlain
target:self
action:@selector(showRight)]; // 手势左右滑动屏幕
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(showRight)];
[swipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
[self.view addGestureRecognizer:swipeLeft]; UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(showLeft)];
[swipeRight setDirection:UISwipeGestureRecognizerDirectionRight];
[self.view addGestureRecognizer:swipeRight]; self.navigationItem.rightBarButtonItem = right;
} // 显示左边抽屉
- (void)showLeft
{
RPTwoTableViewController *c = [[RPTwoTableViewController alloc] init]; // 设置主控制器移动后留下的视图宽度
[self.revealSideViewController changeOffset:RPOffset forDirection:PPRevealSideDirectionLeft]; // 显示子控制器
[self.revealSideViewController pushViewController:c onDirection:PPRevealSideDirectionLeft withOffset:RPOffset animated:YES completion:^{
PPRSLog(@"This is the left!");
}];
} // 显示右边
- (void)showRight
{
RPOneViewController *c = [[RPOneViewController alloc] init]; // 设置主控制器移动后留下的视图宽度
[self.revealSideViewController changeOffset:RPOffset forDirection:PPRevealSideDirectionRight]; // 显示子控制器
[self.revealSideViewController pushViewController:c onDirection:PPRevealSideDirectionRight withOffset:RPOffset animated:YES completion:^{
PPRSLog(@"This is the right!");
}];
}

Demo:

https://github.com/RinpeChen/PPRevealSideViewControllerDemoByRinpe

最新文章

  1. archlinux 加载loop模块,且设定loop设备个数
  2. ASP.NET(C#) Web Api通过文件流下载文件到本地实例
  3. IOS监听屏幕状态
  4. Remoting&WebService的区别之处
  5. 【整理】动态加载Web Services
  6. C#单独启动进程的几种方式
  7. PS基础学习 2---图层蒙版
  8. link方式安装Eclispe插件:greenUML
  9. UVA 558 Wormholes
  10. 【转】Ubuntu常用软件合集
  11. 解决Spring中singleton的Bean依赖于prototype的Bean的问题
  12. Home键的获取监听,安卓4.0后就不能在onkeydown方法中获取了。怎么办。
  13. Python可视化学习(1):Matplotlib的配置
  14. 新建JSPWeb应用
  15. Android开发使用Java8新特性
  16. 自定义仪表盘PaneView
  17. 洛谷P1333 瑞瑞的木棍(欧拉回路)
  18. 【Linux】Linux系统硬链接和软链接
  19. 堆-STL
  20. 个人在 laravel 开发中使用到的一些技巧(持续更新)

热门文章

  1. Prime Path
  2. Linux&shell之Shell脚本
  3. a trick in reading and storing file in the exact way!
  4. LNMP搭建(CentOS 6.3+Nginx 1.2.0+PHP 5.3.15(fpm)+ MySQL 5.5.35)
  5. 汇编学习笔记(7)call和ret指令
  6. 转:给C++初学者的50个忠告
  7. 【26】Remove Duplicates from Sorted Array
  8. CodeForces 221(div 2)
  9. kickstrt脚本for cobbler基于system-config-kickstart配置
  10. 平衡树(AVL)详解