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

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

使用PPRevealSideViewController实现侧滑效果的更多相关文章

  1. iOS 下如果存在UIScrollerView 使用UIScreenEdgePanGestureRecognizer实现侧滑效果失效的问题

    当你在使用UIScreenEdgePanGestureRecognizer手势实现侧滑的时候,如果后期你导航控制器push出的界面中包含UIScrollerView,这个时候你会发现,侧滑效果无法实现 ...

  2. 搜索菜单栏侧滑效果控件SearchView

    搜索菜单栏侧滑效果控件SearchView 本人视频教程系类   iOS中CALayer的使用 效果1: 效果2: 项目中用到的图片 bgImg@2x.png: 源码: SearchView.h + ...

  3. Android使用DrawerLayout仿qq6.6版本侧滑效果

      一讲到侧滑菜单,我相信大家都会想到一个开源控件SlidingMenu,在google还没有出来DrawerLayout的时候几乎都是使用Slidingmenu来实现侧滑效果,可以说是效果很不错,自 ...

  4. android侧滑效果(引用官方网站提供的API文件)

    原文地址:http://www.cnblogs.com/android100/p/android-SlidingMenu.html 在新浪微博和唱吧里面都有看到android的侧滑效果,于是想要学习一 ...

  5. 使用Design包实现QQ动画侧滑效果和滑动菜单导航

    Google在2015的IO大会上,给我们带来了更加详细的Material Design设计规范,同时,也给我们带来了全新的Android Design Support Library,在这个supp ...

  6. 安卓开发笔记——自定义HorizontalScrollView控件(实现QQ5.0侧滑效果)

    对于滑动菜单栏SlidingMenu,大家应该都不陌生,在市场上的一些APP应用里经常可以见到,比如人人网,FaceBook等. 前段时间QQ5.0版本出来后也采用了这种设计风格:(下面是效果图) 之 ...

  7. 仿QQ5.0以上新版本侧滑效果

    1.此效果使用了csdn大神孙国威的代码案例在此感谢附上参考博客地址: http://blog.csdn.net/manoel/article/details/39013095/#plain 2.sl ...

  8. 再造 “手机QQ” 侧滑菜单(一)——实现侧滑效果

    本系列文章中,我们将尝试再造手机QQ的侧滑菜单,力争最大限度接近手Q的实际效果,并使用 Auto Layout 仿造左侧菜单,实现和主视图的联动. 代码示例:https://github.com/jo ...

  9. 微信小程序之实现页面缩放式侧滑效果

    效果图: 实现原理:点击按钮,往需要动画的div中添加或移除拥有动画效果的class. 由于微信小程序中不能操作page这个根节点,所以,只有用一个div(view)来模仿page根节点. 1.结构 ...

随机推荐

  1. codeforces C. Mashmokh and Numbers

    题意:给你n和k,然后让你找出n个数使得gcd(a1,a2)+gcd(a3,a4)+......的和等于k: 思路:如果n为奇数,让前n-3个数的相邻两个数都为1,n-2和n-1两个数gcd为k-an ...

  2. mysql 安装补充

    1:假如下载的文件名为:mysql-5.0.45.tar.gz 2:假如copy到 /usr/local下 3:groupadd mysql #添加mysql组 4:useradd -g mysql ...

  3. C++中强制变换之const_cast

    今天学习了一下C++中的强制转换,看了const_cast,我发现了这个转换关键字的奇怪之处,于是把它记录一下,废话不说,先看一个程序: #include <iostream> using ...

  4. 【单调栈】Vijos P1926 紫色的手链

    题目链接: https://vijos.org/p/1926 题目大意: 给n个数(n<=100 000),求任意区间的最大值异或次大值的最大值. 题目思路: [模拟][单调栈] 我们维护一个严 ...

  5. Merge Intervals——LeetCode

    Given a collection of intervals, merge all overlapping intervals. For example,Given [1,3],[2,6],[8,1 ...

  6. osg配置

    编辑器加载中..OSG+VS2010+win7环境搭建 Win7下 osg+vs2010环境搭建 一.相关准备 a) Osg源码 当前最新版:OpenSceneGraph的3.0.0.zip 下载链接 ...

  7. word 2010中如何创建多级目录和多级列表

    原文地址:http://wenku.baidu.com/link?url=KkSmYTqogxA5VJkLCGb957E5fIGN5S50FUx7IpAWWWKWWRYvaeGl2IvX-dFP25r ...

  8. SRM 394(1-250pt)

    DIV1 250pt 题意:给定一个字符串s('a'-'z'),计其中出现次数最多和最少的字母分别出现c1次和c2次,若在s中去掉最多k个字母,求去掉以后c1 - c2的最小值. 解法:做题的时候,想 ...

  9. 简单的FIRST+集演示程序

    /* * 该程序用于计算某个非终结符的 FIRST+ 集合 * RexfieldVon * 2013年6月30日16:02:47 */ #include <stdio.h> #includ ...

  10. zoj 3462

    #include <cstdio> #include <cmath> #include <algorithm> #include <iostream> ...