iOS RESideMenu 侧滑 第三方类库
下载地址:https://github.com/romaonthego/RESideMenu
效果如下:官方案例

自己的实现效果

具体代码下:
AppDelegate.m文件中
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions方法
DEMOLeftMenuViewController *leftMenuViewController = [[DEMOLeftMenuViewController alloc] init];
RESideMenu *sideMenuViewController = [[RESideMenu alloc] initWithContentViewController:[[MainTabBarController alloc]init] leftMenuViewController:leftMenuViewController rightMenuViewController:[UINavigationController new]];
sideMenuViewController.backgroundImage = [UIImage imageNamed:@"005.jpg"];
sideMenuViewController.menuPreferredStatusBarStyle = ; // UIStatusBarStyleLightContent
sideMenuViewController.delegate = self;
// sideMenuViewController.parallaxContentMaximumRelativeValue=100;
// sideMenuViewController.bouncesHorizontally=YES;
sideMenuViewController.contentViewShadowColor = [UIColor blackColor];
sideMenuViewController.contentViewShadowOffset = CGSizeMake(, );
sideMenuViewController.contentViewShadowOpacity = 0.6;
sideMenuViewController.contentViewShadowRadius = ;
// sideMenuViewController.contentViewShadowEnabled = YES;
// sideMenuViewController.panFromEdge=NO;
self.window.rootViewController = sideMenuViewController;
左侧的控制器DEMOLeftMenuViewController.h和DEMOLeftMenuViewController.m
#import <UIKit/UIKit.h>
#import "RESideMenu.h" @interface DEMOLeftMenuViewController : UIViewController<UITableViewDataSource, UITableViewDelegate, RESideMenuDelegate> @end
#import "DEMOLeftMenuViewController.h"
#import "HomeViewController.h"
#import "UIViewController+RESideMenu.h"
#import "LoginViewController.h"
#import "resigeViewController.h" @interface DEMOLeftMenuViewController ()
@property (strong, readwrite, nonatomic) UITableView *tableView; @end @implementation DEMOLeftMenuViewController - (void)viewDidLoad
{
[super viewDidLoad];
self.navigationController.title=@"登陆";
self.tableView = ({
UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(, (self.view.frame.size.height - * ) / 2.0f, self.view.frame.size.width, * ) style:UITableViewStylePlain];
tableView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleWidth;
tableView.delegate = self;
tableView.dataSource = self;
tableView.opaque = NO;
tableView.backgroundColor = [UIColor clearColor];
tableView.backgroundView = nil;
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
tableView.bounces = NO;
tableView.scrollsToTop = NO;
tableView;
});
[self.view addSubview:self.tableView];
} #pragma mark -
#pragma mark UITableView Delegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
switch (indexPath.row) {
case :
[self presentViewController:[[UINavigationController alloc] initWithRootViewController:[[LoginViewController alloc] init]] animated:YES completion:nil];
break;
case :
[self presentViewController:[[UINavigationController alloc] initWithRootViewController:[[resigeViewController alloc] init]] animated:YES completion:nil];
break;
default:
break;
}
} #pragma mark -
#pragma mark UITableView Datasource - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return ;
} - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return ;
} - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)sectionIndex
{
return ;
} - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
cell.backgroundColor = [UIColor clearColor];
cell.textLabel.font = [UIFont fontWithName:@"HelveticaNeue" size:];
cell.textLabel.textColor = [UIColor whiteColor];
cell.textLabel.highlightedTextColor = [UIColor lightGrayColor];
cell.selectedBackgroundView = [[UIView alloc] init];
} NSArray *titles = @[@"Home", @"Calendar", @"Profile", @"Settings", @"Log Out"];
NSArray *images = @[@"IconHome", @"IconCalendar", @"IconProfile", @"IconSettings", @"IconEmpty"];
cell.textLabel.text = titles[indexPath.row];
cell.imageView.image = [UIImage imageNamed:images[indexPath.row]]; return cell;
} @end
主页HomeViewController.h和HomeViewController.m实现侧滑的关键代码
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"个人中心"
style:UIBarButtonItemStylePlain
target:self
action:@selector(presentLeftMenuViewControl
这个第三番可以实现很多效果
总结
优点:
1.里面的文件较少,不需要使用cocoapods即可运行。
2.里面自定义API也比较多,可以设置变小的抽屉效果或者不变小。
3.里面有两个事例程序,一个是纯手码,一个是Storyboard得。可见作者也非常喜欢IB开发,此框架用IB开发应该可以完美兼容。
4.可以使用手势拖来拖去。
5.项目里各个文件不需要继承,导入头文件就行。
缺点:
1.左边显示的菜单可选项是固定的几个button,暂时想把左边换成tableView还不知道可不可行。
2.不能实现状态栏右移。
3.暂时没找到两边控制器的占比怎么自定义。
iOS RESideMenu 侧滑 第三方类库的更多相关文章
- IOS网络编程——第三方类库
IOS网络编程——第三方类库 目录 概述 ASIHttpRequest AFNetworking 其他 概述 ASIHttpRequest AFNetworking 其他
- iOS开发引入第三方类库的问题
在开发iOS程序的过程中,通常在导入第三方的类库(.a/.o)文件会报出一系列的错误: Undefined symbols for architecture i386: "std::stri ...
- 在ios中使用第三方类库
在项目开发中经常会用到一些第三方类库,通常有两种方法来做到:一种方法是直接把所有的.h和.m文件复制到项目中:另一种方法是把.xcodeproj拖到项目中生成静态链接库并引用. 方法一:直接复制所有源 ...
- ios 下引用第三方类库报错
在最近刚接触的ios的一个项目中用到了腾讯的登录sdk,从git下下来之后编译报错,找不到文件,文件明明已经加入到项目中,为何找不到,由于刚接触ios开发,所有不知道什么原因,经过Google才知道 ...
- OS X第三方类库管理工具cocoapods入门
一.简介 什么是cocoapods?--是OS X和iOS下一个第三方类库管理工具.通过cocoapods,可以为项目添加"Pods"依赖库,并且管理其版本. cocoapods好 ...
- iOS常用第三方类库及Xcode插件
第三方类库(github地址): 1.AFNetworking 网络数据 https://github.com/AFNetworking/AFNetworking 2.SDWebImage 图 ...
- iOS 常用第三方类库、完整APP示例
一.第三方类库 1:基于响应式编程思想的oc地址:https://github.com/ReactiveCocoa/ReactiveCocoa2:hud提示框地址:https://github.com ...
- iOS 如何在一个已经存在多个project的workspace中引入cocoapods管理第三方类库
一种新的第三方库管理工具:Carthage 如何使用Carthage管理iOS依赖库 Podfile Syntax Reference v1.1.0.rc.3 https://guides.cocoa ...
- iOS开发常用的第三方类库
在iOS开发中不可避免的会用到一些第三方类库,它们提供了很多实用的功能,使我们的开发变得更有效率:同时,也可以从它们的源代码中学习到很多有用的东西. Reachability 检测网络连接 用来检查网 ...
随机推荐
- 应用程序框架实战三十:表现层及ASP.NET MVC介绍(一)
本文将介绍表现层及ASP.NET MVC的一些要点,特别是ASP.NET MVC的一些抽象和封装技巧,如果你对MVC还不了解,可以参考<ASP.NET MVC4 高级编程>,作者Jon G ...
- 窥探Swift之别样的枚举类型
想必写过程序的童鞋对枚举类型并不陌生吧,使用枚举类型的好处是多多的,在这儿就不做过多的赘述了.Fundation框架和UIKit中的枚举更是数不胜数,枚举可以使你的代码更易阅读并且可以提高可维护性.在 ...
- 用javascript做一个视频播放器
以前我们在网页上播放视频,都是要麻烦flash来实现.看着那一大段的<object>真心觉得累.随着html5的不断普及,现在是时候使用html5提供的video元素来做点正经事了,但是要 ...
- MVC, MVP, MVVM比较以及区别(下)
上一篇得到大家的关注,非常感谢.一些朋友评论中,希望快点出下一篇.由于自己对于这些模式的理解也是有限,所以这一篇来得迟了一些.对于这些模式的比较,是结合自己的理解,一些地方不一定准确,但是只有亮出自己 ...
- canvas学习(一)
Canvas 学习之路 (一) canvas 是H5 里面神一样的东西,使得只是通过html和js就能做出非常棒的游戏和画面. 因为对前端无限的爱好,更加对canvas充满好奇,将我学习canvas的 ...
- 响应式web布局中iframe的自适应
困境 在响应式布局中,我们应该小心对待iframe元素,iframe元素的width和height属性设置了其宽度和高度,但是当包含块的宽度或高度小于iframe的宽度或高度时,会出现iframe元素 ...
- 【Spring-web】RestTemplate源码学习
2016-12-22 by 安静的下雪天 http://www.cnblogs.com/quiet-snowy-day/p/6210288.html 前言 在Web开发工作中,有一部分开发任务 ...
- maven全局配置文件settings.xml详解
概要 settings.xml有什么用? 如果在Eclipse中使用过Maven插件,想必会有这个经验:配置settings.xml文件的路径. settings.xml文件是干什么的,为什么要配置它 ...
- 从 AJAX 到 JSONP的基础学习
目录索引: 一.AJAX的概念二.POST && GET三.原生实现AJAX简单示例 3.1 实现代码 3.2 重点说明四.框架隐藏域 4.1 基本概念 4.2 后台写入脚本 4.3 ...
- Visual Studio.NET单选题
在Visual Studio.NET窗口中,在__________窗口中可以察看当前项目的类和类型的层次信息. A. 解决方案资源管理器 B. 类视图 C. 资源视图 D. 属性 在线答题:http ...