使用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.结构 ...
随机推荐
- HttpWebRequest.GetResponse() raises exception when http status code 400 (bad request) is returned
参考: .Net HttpWebRequest.GetResponse() raises exception when http status code 400 (bad request) is re ...
- Winform 隐藏程序窗口
internal class HideOnStartupApplicationContext : ApplicationContext { private Form mainFormInternal; ...
- 海量日志数据提取某日访问百度次数最多的那个IP的Java实现
海量日志数据提取某日访问百度次数最多的那个IP的Java实现 前几天在网上看到july的一篇文章<教你如何迅速秒杀掉:99%的海量数据处理面试题>,里面说到百度的一个面试题目,题目如下: ...
- Light OJ 1004 - Monkey Banana Problem(DP)
题目大意: 给你一菱形的数字阵,问从最上面走到最下面所能获得的最大值是多少? #include<cstdio> #include<cstring> #include<io ...
- 数据结构(跳跃表):NOI 2004 郁闷的出纳员
郁闷的出纳员 [问题描述] OIER公司是一家大型专业化软件公司,有着数以万计的员工.作为一名出纳员,我的任务之一便是统计每位员工的工资.这本来是一份不错的工作,但是令人郁闷的是,我们的老板反复无常, ...
- osg
智能指针使用: osg::Geode* geode=new osg::Geode;//新建Geode指针 osg::ref_ptr<osg::Geode>geodePtr=geode;// ...
- 译文链接:http://www.codeceo.com/article/10-truth-programmer-must-know.html
大多数时候,写代码都是挺有意义的一件事,不光能增加经验值,解决难题的时候还特别爽.耐心.毅力.执着,再加上正确的工具——只要有它们的亲密协作,优雅.漂亮的代码就是手到擒来的事儿. 但是,紧接着拙劣的资 ...
- Xcode use Protocol buffer
http://stackoverflow.com/questions/10277576/google-protocol-buffers-on-ios http://stackoverflow.com/ ...
- Swing实现文件选择(目录选择)附导出
具体生成工具如图: (1) (2) (3) (4) 源码 : example.java package org.qiailin.jframe; import java.awt.Container; i ...
- Scrapy:Python的爬虫框架
网络爬虫,是在网上进行数据抓取的程序,使用它能够抓取特定网页的HTML数据.虽然我们利用一些库开发一个爬虫程序,但是使用框架可以大大提高效率,缩短开发时间.Scrapy是一个使用Python编写的,轻 ...