IOS学习之路十(仿人人滑动菜单Slide-out Sidebar Menu)

2013-09-03 22:13 by lixingle, 270 阅读, 0 评论, 收藏编辑

最近滑动菜单比较流行,像facebook和人人等都在使用滑动菜单,今天做了一个小demo大体效果如下:

这次用了一个开源的项目ECSlidingViewController这个也是一个挺著名的托管在Github上的开源项目:

Github上Project的URL是:https://github.com/edgecase/ECSlidingViewController

大体步骤如下:

创建一个SingleView applicaton:

下面把下载的源码包含进来:

解压缩后打开 找到   ECSlidingViewController/Vendor/ECSlidingViewController 下的两个文件,我们把整个Vendor文件夹都导入:

添加一个类库:

打开StoryBoard另外再创建两个UIViewController

创建后大概界面如下:

1.新建两个文件分别为:ToDoViewController和MenuViewController都继承于UIviewController:

2.把新建时自带的ViewController两个文件删除,新建一个文件为:InitialSlidingViewController,打开stroryBoard并把它设为RootViewController。

3.在stroryBoard中把刚才新建的两个ToDoViewController和MenuViewController进行设置:

先设置ToDoViewController:把controller类设为:ToDoViewController标示符设为:ToDoView

MenuViewController的设置如上:把controller类设为:MenuViewController标示符设为:MenuView

下面修改代码:

  1. InitialSlidingViewController.m
  1. #import "InitialSlidingViewController.h"
  2. #import "ToDoViewController.h"
  3. @interface InitialSlidingViewController ()
  4. @end
  5. @implementation InitialSlidingViewController
  6. - (void)viewDidLoad
  7. {
  8. [super viewDidLoad];
  9. self.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"ToDoView"];
  10. }
  11. @end

ToDoViewController.m:中修改如下:

  1. - (void)viewWillAppear:(BOOL)animated
  2. {
  3. [super viewWillAppear:animated];
  4. // Add a shadow to the top view so it looks like it is on top of the others
  5. self.view.layer.shadowOpacity = 0.75f;
  6. self.view.layer.shadowRadius = 10.0f;
  7. self.view.layer.shadowColor = [[UIColor blackColor] CGColor];
  8. // Tell it which view should be created under left
  9. if (![self.slidingViewController.underLeftViewController isKindOfClass:[MenuViewController class]]) {
  10. self.slidingViewController.underLeftViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"MenuView"];
  11. }
  12. // Add the pan gesture to allow sliding
  13. [self.view addGestureRecognizer:self.slidingViewController.panGesture];
  14. }

MenuViewController修改如下:

  1. - (void)viewDidLoad
  2. {
  3. [super viewDidLoad];
  4. [self.slidingViewController setAnchorRightRevealAmount:240.0f];
  5. self.slidingViewController.underLeftWidthLayout = ECFullWidth;
  6. }

为了美观你可以设置一下ToDoViewController和MenuViewController的背景色:

运行一下效果大体如下:

接下来你可以自己添加个性的View和segue了

转载请注明:
原文转载自:http://blog.csdn.net/wildcatlele

新浪微博:http://weibo.com/u/3202802157

原文参考:http://kingscocoa.com/tutorials/slide-out-navigation/

Slide-out Sidebar Menu的更多相关文章

  1. iphone Dev 开发实例10:How To Add a Slide-out Sidebar Menu in Your Apps

    Creating the Xcode Project With a basic idea about what we’ll build, let’s move on. You can create t ...

  2. IOS学习之路十(仿人人滑动菜单Slide-out Sidebar Menu)

    最近滑动菜单比较流行,像facebook和人人等都在使用滑动菜单,今天做了一个小demo大体效果如下: 这次用了一个开源的项目ECSlidingViewController这个也是一个挺著名的托管在G ...

  3. 40 个超棒的免费 Bootstrap HTML5 网站模板

    Bootstrap 是快速开发Web应用程序的前端工具包.它是一个CSS和HTML的集合,它使用了最新的浏览器技术,给你的Web开发提供了时尚的版式,表单,buttons,表格,网格系统等等. 目前 ...

  4. Bootstrap Metronic 学习记录(二)菜单栏

    1.简介 1)  .环境配置 2)  .提取页面 2).动态生成菜单(无限级别树) 2.系统环境配置 项目需要程序数据支撑,这里选择MVC5.0+EF6.0[SQLSERVER](不对MVC架构和SQ ...

  5. 240个jquery插件(转)

    http://www.kollermedia.at/archive/2007/11/21/the-ultimate-jquery-plugin-list/File upload Ajax File U ...

  6. 很不错的jQuery学习资料和实例

    这些都是学习Jquery很不错的资料,整理了一下,分享给大家. 希望能对大家的学习有帮助. 帕兰 Noupe带来的51个最佳jQuery教程和实例, 向大家介绍了jQuery的一些基本概念和使用的相关 ...

  7. 强烈推荐240多个jQuery插件提供下载

    jQuery 是继 prototype 之后又一个优秀的 Javascript 框架.其宗旨是—写更少的代码,做更多的事情.它是轻量级的 js 库(压缩后只有21k) ,这是其它的 js 库所不及 的 ...

  8. 240多个jQuery插件

    概述 jQuery 是继 prototype 之后又一个优秀的 Javascript 框架.其宗旨是—写更少的代码,做更多的事情.它是轻量级的 js 库(压缩后只有21k) ,这是其它的 js 库所不 ...

  9. 海量jQuery插件

    转自:http://blog.csdn.net/zzq58157383/article/details/6900142 提醒大家在使用的时候注意jQuery包的版本问题,最好是使用相同的版本,因为使用 ...

随机推荐

  1. HDU 1686 Oulipo(kmp)

    Problem Description The French author Georges Perec (1936–1982) once wrote a book, La disparition, w ...

  2. 汉字转整数,比系统简单易用!a2iLxx (覆盖物 16十六进制,VC6亲测可用)请提供意见~

    #include "string.h" #define INVALID_VALUE_LXX ((1 << (8 * sizeof(int) -1)) - 1) /*有符 ...

  3. hive union all 使用

    功能:将两个表中的 同样的字段拼接到一起 測试: create external table IF NOT EXISTS temp_uniontest_ta ( a1 string, a2 strin ...

  4. Ionic项目中使用极光推送-android

    对于Ionic项目中使用消息推送服务,Ionic官方提供了ngCordova项目,这个里面的提供了用angularjs封装好的消息推送服务(官方文档),使用的是GitHub上的 PushPlugin ...

  5. linux简单的数据包捕获分析

    有时我们会遇到一些问题,需要捕捉数据包分析,当手头有没有专业的抓图工具,您可以使用tcpdump相反,看看(一般版本附带这个工具) 比如,我们要分析eth0与接口192.168.7.188 这个对象I ...

  6. HDU 4228 Flooring Tiles 反素数

    推出了结论,万万没想到最后用搜索.. 还想dp来着.. #include <cstdio> #include <cstring> #include <iostream&g ...

  7. Django查询的琐碎记录

    我的需求是这样的,获取指定用户的获“赞”总数. 用户 models.py class UserProfile(models.Model): user = models.OneToOneField(Us ...

  8. div、ul、li等无法居中问题,text-align无效 margin auto无效

    很简单.如果是div,直接把div换成: <table align="center">        <tr>            <td> ...

  9. Windows 8 常用第三方SDK使用概览

    原文:Windows 8 常用第三方SDK使用概览 应用开发过程中,我们或多或少会使用到第三方的公司平台的功能,例如:新浪微博.人人网.高德地图等. 那么在Windows 8 Store App开发中 ...

  10. Tomcat7.0更改默认的路径来访问自己的项目

    如何使自己的项目没有输入:localhost:8080/项目名称/index.html 能够访问. 步骤,如下面的 : 找到tomcat ---  config----server.xml 选中右键编 ...