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 检测网络连接 用来检查网 ...
随机推荐
- [ROS] Studying Guidance
Reference: https://www.zhihu.com/question/35788789 安装指南:http://wiki.ros.org/indigo/Installation/Ubun ...
- 使用MAT(Memory Analyzer Tool)工具分析dump文件--转
原文地址:http://gao-xianglong.iteye.com/blog/2173140?utm_source=tuicool&utm_medium=referral 前言 生产环境中 ...
- swift 中指针的使用UnsafeMutablePointer
在swift中已经弱化了指针的使用,可以这么使用 let s: NSRange = NSMakeRange(, ) let at = UnsafeMutablePointer<NSRange&g ...
- 【Java】 环境变量如何配置?
Java知识简介与环境变量配置问题 一.在学习一门语言中,不仅需要掌握其语法结构,开发平台以及环境也是很重要的.在开始Java学习之前首先对其进行压缩包的下载安装,以及开发平台环境下载安装.基于此下面 ...
- Oracle 数据库重放(Database Replay)功能演示
我们可以捕获生产环境的工作量,在测试环境上重放,从而在不影响生产环境的前提下做一些改动测试. 捕获:需要Oracle版本为10.2.0.4或更高. 重放:需要Oracle版本为11g Release ...
- 1.Java基础之System对象
毕向东老师Java基础学习笔记——System对象 今天学习Java中的System对象后,感觉这个对象对我们主要有以下几点用处. 1.获取当前操作系统版本和类型. 2.获取当前操作系统的path中的 ...
- maven 插件
一直没注意看maven执行过程中的打印日志,今天突然发现一段话,说编译以及resource未指定编码,默认gbk.于是,百度了设置编码的方式: <plugin> <groupId&g ...
- 现代Web应用开发者必备的六大技能
过去,应用开发需要注重大量的专业知识,程序员只需关注单一的语言(比如COBOL.RPG.C++等),并利用该语言创建应用.而如今,时代在变迁.Web不再是单单关注独立的一面.相反,一个现代化的Web应 ...
- 微信小程序(应用号)开发体验
昨天微信小程序(应用号)内测的消息把整个技术社区炸开了锅, 我也忍不住跟了几波,可惜没有内测资格,听闻破解版出来了, 今天早上就着原来的项目资源试开发了一下,总结一下体验. 总体体验 开发效率高,6: ...
- WinForm 代码实现以管理员身份运行
[STAThread] static void Main(string[] Args) { //获得当前登录的Windows用户标示 System.Security.Principal.Windows ...