说道抽屉效果在iOS中比较有名的第三方类库就是PPRevealSideViewController。一说到第三方类库就自然而然的想到我们的CocoaPods,今天的博客中用CocoaPods引入PPRevealSideViewController,然后在我们的工程中以代码结合storyboard来做出抽屉效果。

  一.在工程中用CocoaPods引入第三方插件PPRevealSideViewController.

    (1).在终端中搜索PPRevealSideViewController的版本

  

    (2).在Podfile中添加相应的版本库

    (3).之后保存一下Podfile文件,然后执行pod install即可

  二、为我们的工程添加pch文件

    因为用的是XCode6, 上面默认是没有pch文件的,如果我们想使用pch文件,需要手动添加,添加步骤如下

    1.在XCode6中是么有pch文件的,如下图

    2.创建pch文件

    

    3.配置pch文件

      (1)、找工程的Targets->Build Settings->Apple LLVM 6.0 - Language

 

      (2)在Prefix Header下面的Debug和Release下添加$(SRCROOT)/工程名/pch文件,入下图

    

  三、使用PPRevealSideViewController来实现抽屉效果

    当然了首先在pch文件中引入我们的第三方类库,然后使用即可

    1.在storyboard拖出来我们要用的视图控制器,点击主界面上的按钮会以抽屉的形式展示出导航页,然后在导航页导航到各个界面,之后在从各个页面回到主界面

    2.在AppDelegate中初始化我们的PPRevealSideViewController并设置为启动页面代码如下:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {// Override point for customization after application launch.self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];//获取主视图的导航控制器UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"NavigationController"];//新建PPRevealSideViewController,并设置根视图(主页面的导航视图)PPRevealSideViewController *sideViewController = [[PPRevealSideViewController alloc] initWithRootViewController:vc];sideViewController.fakeiOS7StatusBarColor = [UIColor whiteColor];//把sideViewController设置成根视图控制器self.window.rootViewController = sideViewController;[self.window makeKeyAndVisible];return YES;
}

    3.在主界面使用PPRevealSideViewController来推出导航页

- (IBAction)tapItem:(id)sender {UIStoryboard *storybaord = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];UITableViewController *table = [storybaord instantiateViewControllerWithIdentifier:@"CustomViewViewController"];[self.revealSideViewController pushViewController:table onDirection:PPRevealSideDirectionLeft animated:YES];
}

    4.在导航页点击不同的按钮使用PPRevealSideViewController跳转到不同的controller

- (IBAction)tap1:(id)sender {UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];UIViewController *one = [storyboard instantiateViewControllerWithIdentifier:@"one"];[self.revealSideViewController popViewControllerWithNewCenterController:one animated:YES];
}- (IBAction)tap2:(id)sender {UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];UIViewController *one = [storyboard instantiateViewControllerWithIdentifier:@"two"];[self.revealSideViewController popViewControllerWithNewCenterController:one animated:YES];}- (IBAction)tap3:(id)sender {UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];UIViewController *one = [storyboard instantiateViewControllerWithIdentifier:@"three"];[self.revealSideViewController popViewControllerWithNewCenterController:one animated:YES];
}- (IBAction)tap4:(id)sender {UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];UIViewController *one = [storyboard instantiateViewControllerWithIdentifier:@"four"];[self.revealSideViewController popViewControllerWithNewCenterController:one animated:YES];
}

    5.各个页面返回到主界面的代码如下:

- (IBAction)tapPage:(id)sender {UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];UIViewController *view = [storyboard instantiateViewControllerWithIdentifier:@"NavigationController"];[self.revealSideViewController popViewControllerWithNewCenterController:view animated:YES];
}

四.到此效果实现完毕,下面是效果图:

iOS开发之抽屉效果实现相关推荐

  1. iOS开发之抽屉效果

    2019独角兽企业重金招聘Python工程师标准>>> 在显示在窗口的控制器上添加三个view(如果只需要往一边滑动就只加2个view) 先声明三个view #import &quo ...

  2. iOS开发手机震动效果

    首先要导入 #import <AudioToolbox/AudioToolbox.h> 一行代码搞定: AudioServicesPlaySystemSound(kSystemSoundI ...

  3. ios开发学习-手势交互(Gesture)效果源码分享

    qianqianlianmeng ios开发学习-手势交互(Gesture)效果源码分享 All Around Pull View 介绍:实现视图四个方向(上下左右)都能够拖动更新(pull to r ...

  4. iOS开发 QQ粘性动画效果

    QQ(iOS)客户端的粘性动画效果 时间 2016-02-17 16:50:00  博客园精华区 原文  http://www.cnblogs.com/ziyi--caolu/p/5195615.ht ...

  5. iOS开发之各种动画各种页面切面效果

    转发:http://www.cocoachina.com/ios/20141226/10775.html 今天所介绍的主题是关于动画的,在之前的博客中也有用到动画的地方,今天就好好的总结一下iOS开发 ...

  6. android 3d侧拉抽屉,iOS动画指南 - 4.右拉的3D抽屉效果

    一切的动画其实都是假象,3D效果也是这样.本篇我们来做一个这样的特效. 先忽略掉3D效果,我们先要做的是一个右拉的抽屉效果. 总体思路: 1.创建一个ContainerViewController容器 ...

  7. 安卓开发SlidingDrawer实现抽屉效果

    在手机开发中,我们会遇到这样的问题,要在手机屏幕上显示很多信息,但是手机屏幕就那么小一点,当内容较多的时候如何显示呢,我们如何理用更有限的空间来显示更多的信息呢?我们可以使用安卓系统提供的Slidin ...

  8. 2.7 实现强大的单元格左右滑动效果并添加功能按钮 [iOS开发中的神兵利器]

    原文:http://coolketang.com/staticCoding/5a995103d50eee2ea30512f9.html 1. 您将在本节课对单元格进行扩展,当鼠标在单元格左右滑动时,弹 ...

  9. 防ios的抽屉效果,防qq的抽屉效果

    AS中导入GitHub开源项目SlidingMenu总结,我开始AS导入SlidingMenu的时候也百度了很多文章,写的都不是很详细,所以导入成功后,写了这篇文章,希望对想用AndroidStudi ...

最新文章

  1. 全球 Top 1000 计算机科学家 h 指数公布,中国顶尖计算机科学家人数进入前三
  2. 中科大京东最新成果:让AI像真人一样演讲,手势打得惟妙惟肖
  3. 用python画爱心的代码-怎么用python实现画爱心
  4. 最全的时间类解析。 SimpleDateFormat + Date() 和 DateTimeFormatter + LocalDate()的区别与使用场景
  5. JS实现的展开隐藏效果
  6. 如何格式化电脑_移动硬盘提示格式化如何解决?数据恢复软件解决问题
  7. python位运算符_详细介绍Python语言中的按位运算符
  8. 计算机内部总线和外部总线,科学网-怎样将计算机内部总线扩展为外部网络?-姜咏江的博文...
  9. DWZUI(1.3)框架中遇到的两个问题
  10. 怎么判断tcp重组完成_网络工程师(8):TCP为什么可靠
  11. 集成服务入门(实验7)数据流的目标
  12. Raphael的set使用
  13. bzoj 2464: 中山市选[2009]小明的游戏(BFS)
  14. 对抗 | 利用de4dot解密被混淆的.NET代码
  15. 一个著名防外挂软件,下面转载一遍关于nProtect的破解
  16. 2020-06-10
  17. ps还原上一步快捷键,ps返回上一步快捷键是什么
  18. python 进行文本情感分析
  19. 阿尔法营任务黑客机器人游戏答案
  20. Matlab-syms用法

热门文章

  1. 卡内基梅隆大学机器学习系副主任邢波:AI落地现在最缺的是思维方式
  2. 中国数字化进程比发达国家快,小程序让我感到自豪 | IT领袖峰会
  3. 人工智能产业2018年待解的三大难题
  4. Face++印奇:从无人问津到融资4.6亿美金|纪录影片
  5. CTO 写的低级 Bug 再致网站被黑,CEO 的号都被盗了!
  6. 阿里当 PM 需要做什么?程序媛的亲身经历告诉你!| 程序员有话说
  7. NO7 利用三剑客awk-grep-sed-head-tail等7种方法实践
  8. shell脚本常用脚本:while
  9. 从零开始机器学习比赛经验(bird分享)
  10. vmware nat模式原理探究,实现虚拟机跨网段管理