使用PPRevealSideViewController实现侧滑效果
使用起来还是比较简单的, 主要是几个步骤
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实现侧滑效果的更多相关文章
- iOS 下如果存在UIScrollerView 使用UIScreenEdgePanGestureRecognizer实现侧滑效果失效的问题
当你在使用UIScreenEdgePanGestureRecognizer手势实现侧滑的时候,如果后期你导航控制器push出的界面中包含UIScrollerView,这个时候你会发现,侧滑效果无法实现 ...
- 搜索菜单栏侧滑效果控件SearchView
搜索菜单栏侧滑效果控件SearchView 本人视频教程系类 iOS中CALayer的使用 效果1: 效果2: 项目中用到的图片 bgImg@2x.png: 源码: SearchView.h + ...
- Android使用DrawerLayout仿qq6.6版本侧滑效果
一讲到侧滑菜单,我相信大家都会想到一个开源控件SlidingMenu,在google还没有出来DrawerLayout的时候几乎都是使用Slidingmenu来实现侧滑效果,可以说是效果很不错,自 ...
- android侧滑效果(引用官方网站提供的API文件)
原文地址:http://www.cnblogs.com/android100/p/android-SlidingMenu.html 在新浪微博和唱吧里面都有看到android的侧滑效果,于是想要学习一 ...
- 使用Design包实现QQ动画侧滑效果和滑动菜单导航
Google在2015的IO大会上,给我们带来了更加详细的Material Design设计规范,同时,也给我们带来了全新的Android Design Support Library,在这个supp ...
- 安卓开发笔记——自定义HorizontalScrollView控件(实现QQ5.0侧滑效果)
对于滑动菜单栏SlidingMenu,大家应该都不陌生,在市场上的一些APP应用里经常可以见到,比如人人网,FaceBook等. 前段时间QQ5.0版本出来后也采用了这种设计风格:(下面是效果图) 之 ...
- 仿QQ5.0以上新版本侧滑效果
1.此效果使用了csdn大神孙国威的代码案例在此感谢附上参考博客地址: http://blog.csdn.net/manoel/article/details/39013095/#plain 2.sl ...
- 再造 “手机QQ” 侧滑菜单(一)——实现侧滑效果
本系列文章中,我们将尝试再造手机QQ的侧滑菜单,力争最大限度接近手Q的实际效果,并使用 Auto Layout 仿造左侧菜单,实现和主视图的联动. 代码示例:https://github.com/jo ...
- 微信小程序之实现页面缩放式侧滑效果
效果图: 实现原理:点击按钮,往需要动画的div中添加或移除拥有动画效果的class. 由于微信小程序中不能操作page这个根节点,所以,只有用一个div(view)来模仿page根节点. 1.结构 ...
随机推荐
- Unity3d 项目管理
Unity3d 项目管理 1.项目管理采用TortoiseSVN方式进行管理,但是也要结合人员管理的方式,尽量在U3D中多采用Scene(关卡的方式),以一下目录的方式进行管理! 以名字的方式进行合 ...
- KeilC51使用详解 (一)
第一节 系统概述 Keil C51是美国Keil Software公司出品的51系列兼容单片机C语言软件开发系统,与汇编相比,C语言在功能上.结构性.可读性.可维护性上有明显的优势,因而易学易用.用过 ...
- RS232及RTS和CTS
EIA RS-232-C标准 EIA RS-232-C是由美国电子工业协会EIA制定的串行通信物理接口标准.最初是远程数据通信时,为连接数据终端设备DTE(Data Terminal Equipmen ...
- Lesson 6: CronTrigger
CronTrigger is often more useful than SimpleTrigger, if you need a job-firing schedule that recurs b ...
- aix ipcs使用说明
ipcs: -q Writes information about active message queues -o Writes the following usage ...
- hdu-2586-How far away ?(离线LCA)
题意: 给定一棵树,每条边都有一定的权值,q次询问,每次询问某两点间的距离. 分析: 这样就可以用LCA来解,首先找到u, v 两点的lca,然后计算一下距离值就可以了. 这里的计算方法是,记下根结点 ...
- Delphi WEB APP DEBUGGER是如何使用的
WEB APP DEBUGGER是怎么使用的最近在写一个WEBSERVICE的程序,怎么设置使用,WEBAPPDEBUGGER这个工具呢,让别人在调用我的WEBSERVICE的时候我可以调试的?谢 ...
- bithrtree
#include "stdio.h" #include "stdlib.h" #define OK 1 #define ERROR 0 typedef char ...
- MySQL错误代码大全
130 :文件格式不正确.(还不是很清楚错误的状况)145 :文件无法打开.1005:创建表失败.1006:创建数据库失败.1007:数据库已存在,创建数据库失败.1008:数据库不存在,删除数据库 ...
- linux0.12 解决编译问题常用命令
解决编译问题时,经常需要修改所有的Makefile,特别定义了下面几条命令方便修改. function msed() { find -name "Makefile" -exec s ...