iOS 隐藏系统的导航,使用自定义的导航
#import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @end
#import "AppDelegate.h"
#import "RootViewController.h"
@interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor]; UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:[[RootViewController alloc] init]];
//隐藏系统导航栏
navigation.navigationBarHidden = YES;
self.window.rootViewController = navigation; [self.window makeKeyAndVisible];
return YES;
} @end
#import <UIKit/UIKit.h> @interface RootViewController : UIViewController @end
#import "RootViewController.h"
#import "LFNavigationView.h"
#import "ViewController.h"
@interface RootViewController ()<LFNavigationViewDelegate,UITableViewDataSource,UITableViewDelegate>
{
UITableView *_tableView;
}
@property(nonatomic, strong) LFNavigationView *navigationView; @end @implementation RootViewController - (void)loadView{
[super loadView];
_tableView = [[UITableView alloc] initWithFrame:/*[[UIScreen mainScreen] bounds]*/CGRectMake(, , [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height - ) style:UITableViewStylePlain];
_tableView.dataSource = self;
_tableView.delegate = self;
[self.view addSubview:_tableView];
} - (void)viewDidLoad {
[super viewDidLoad];
if([UIDevice currentDevice].systemVersion.floatValue >= ) {
self.edgesForExtendedLayout = UIRectEdgeNone;
self.extendedLayoutIncludesOpaqueBars = NO;
self.modalPresentationCapturesStatusBarAppearance = NO;
}
[self setNavMethod];
} - (void)setNavMethod{
_navigationView = [[LFNavigationView alloc] initWithTitle:@"测试" WithLeftImage:nil WithLeftImageHighlighted:nil WithRightImage:nil WithRightImageHighlighted:nil WithViewControl:self];
[self.view addSubview:_navigationView];
} #pragma mark -- UITableViewDelegate --
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return ;
} - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return ;
} - (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
}
cell.textLabel.text = [NSString stringWithFormat:@"test row:%lu",indexPath.row];
return cell;
} - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
ViewController *viewController = [[ViewController alloc] init];
[self.navigationController pushViewController:viewController animated:YES]; } - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end
#import <UIKit/UIKit.h> @protocol LFNavigationViewDelegate <NSObject> @optional
- (void)leftButtonAction:(UIButton *)button;//左边按钮点击
- (void)rightButtonAction;//右边按钮点击 @end @interface LFNavigationView : UIView @property(nonatomic, weak) UIButton *leftBtn;
@property(nonatomic, weak) UIButton *rigthBtn;
@property(nonatomic, strong) UIImageView *rigthImg;
@property(nonatomic, strong) UILabel *rigthLabel;
@property(nonatomic, strong) UILabel *titleLabel; - (id)initWithTitle:(NSString*)title WithLeftImage:(NSString*)leftImage WithLeftImageHighlighted:(NSString*)leftImageHighlighted WithRightImage:(NSString*)rightImage WithRightImageHighlighted:(NSString*)rigthImagehighlighted WithViewControl:(id<LFNavigationViewDelegate>) delegate; @end
#import "LFNavigationView.h"
@implementation LFNavigationView
- (instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
}
return self;
}
- (id)initWithTitle:(NSString*)title WithLeftImage:(NSString*)leftImage WithLeftImageHighlighted:(NSString*)leftImageHighlighted WithRightImage:(NSString*)rightImage WithRightImageHighlighted:(NSString*)rigthImagehighlighted WithViewControl:(id<LFNavigationViewDelegate>) delegate{
float Y = ;
if ([UIDevice currentDevice].systemVersion.floatValue >= ) {
Y = ;
}
self = [super initWithFrame:CGRectMake(, , [UIScreen mainScreen].bounds.size.width, +Y)];
if (self) {
UIView *bgView = [[UIView alloc] initWithFrame:self.frame];
bgView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"顶栏背景"]];
[self addSubview:bgView];
if (title) {
//标题
_titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(([UIScreen mainScreen].bounds.size.width - )/, Y, , )];
_titleLabel.textAlignment = NSTextAlignmentCenter;
_titleLabel.backgroundColor = [UIColor clearColor];
_titleLabel.text = title;
_titleLabel.textColor = [UIColor whiteColor];
_titleLabel.font = [UIFont systemFontOfSize:];
[self addSubview:_titleLabel];
}
if (leftImage) {
UIImageView *leftImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@",leftImage]] highlightedImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@",leftImageHighlighted]]];
leftImg.frame =CGRectMake(, , , );
[self addSubview:leftImg];
UIImageView *leftTapView = [[UIImageView alloc] initWithFrame:CGRectMake(, +Y, , )];
leftTapView.userInteractionEnabled = YES;
leftTapView.backgroundColor = [UIColor clearColor];
[self addSubview:leftTapView];
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:delegate action:@selector(leftButtonAction:)];
tapGesture.numberOfTouchesRequired = ;
tapGesture.numberOfTapsRequired = ;
[leftTapView addGestureRecognizer:tapGesture];
}
}
if (rightImage) {
_rigthImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@",rightImage]] highlightedImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@",rigthImagehighlighted]]];
_rigthImg.frame = CGRectMake([UIScreen mainScreen].bounds.size.width-, , , );
[self addSubview:_rigthImg];
_rigthLabel = [[UILabel alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - , , , )];
_rigthLabel.textColor = [UIColor whiteColor];
_rigthLabel.font = [UIFont systemFontOfSize:];
[self addSubview:_rigthLabel];
UIImageView *rightTapView = [[UIImageView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - , +Y, , )];
rightTapView.userInteractionEnabled = YES;
rightTapView.backgroundColor = [UIColor clearColor];
[self addSubview:rightTapView];
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:delegate action:@selector(rightButtonAction)];
tapGesture.numberOfTouchesRequired = ;
tapGesture.numberOfTapsRequired = ;
[rightTapView addGestureRecognizer:tapGesture];
}
return self;
}
@end
#import <UIKit/UIKit.h> @interface ViewController : UIViewController @end
#import "ViewController.h"
#import "LFNavigationView.h"
@interface ViewController ()<LFNavigationViewDelegate> @property(nonatomic, strong) LFNavigationView *navigationView; @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor greenColor];
[self setNavMethod];
} - (void)setNavMethod{
_navigationView = [[LFNavigationView alloc] initWithTitle:@"控制器" WithLeftImage:@"返回按钮" WithLeftImageHighlighted:@"返回按钮_down" WithRightImage:@"加号图标" WithRightImageHighlighted:@"加号图标_down" WithViewControl:self];
[self.view addSubview:_navigationView];
} #pragma mark -- LFNavigationViewDelegate --
- (void)leftButtonAction:(UIButton *)button{
NSLog(@"%@",button);
[self.navigationController popToRootViewControllerAnimated:YES];
} -(void)rightButtonAction{
NSLog(@"should do somthing");
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end
iOS 隐藏系统的导航,使用自定义的导航的更多相关文章
- 利用iOS原生系统进行人脸识别+自定义滤镜(GPUImage)
人脸识别+滤镜效果(基于GPUImage实现的自定义滤镜) 最近碰到一个好玩的需求.说要客户端这边判定一下是否有人脸.在有的基础上.对相片做进一步的美化滤镜处理. 首先是人脸的识别判定; //将图片对 ...
- iOS 隐藏自定义tabbar
iOS 隐藏自定义tabbar -(void)viewWillAppear:(BOOL)animated { NSArray *array=self.tabBarController.view.su ...
- ios7隐藏系统底部导航
ios7隐藏系统底部导航 minimal-ui <meta id="viewport" name="viewport" content="wid ...
- iOS开发UI篇—使用xib自定义UItableviewcell实现一个简单的团购应用界面布局
iOS开发UI篇—使用xib自定义UItableviewcell实现一个简单的团购应用界面布局 一.项目文件结构和plist文件 二.实现效果 三.代码示例 1.没有使用配套的类,而是直接使用xib文 ...
- iOS回顾笔记(08) -- 自定义Cell的类型和创建步骤总结
iOS回顾笔记(08) -- 自定义Cell的类型和创建步骤总结 项目中我们常见的自定义cell主要分为两种 等高cell:如应用列表.功能列表 非等高cell:如微博列表.QQ聊天页面 下面对这 ...
- 显示iOS所有系统字体
显示iOS所有系统字体 源码地址: https://github.com/YouXianMing/UI-Component-Collection 效果图: 便于你开发中寻找适合自己的字体, demo中 ...
- iOS开发之--最简单的导航按钮更换方法/导航颜色的改变
有很多时候,我们需要用到导航,那么更换导航的时候,是在那用那修改,还是自定义一个导航,或者是声明一个代理方法,经过查资料和对导航属性的一些了解,用一种方法最为简单,就是在入口类里面添加一个方法,调用偏 ...
- html自定义垂直导航菜单(多级导航菜单,去掉font-awesome图标,添加自己的箭头图标)
这次在原先html自定义垂直导航菜单的基础上做了比较大的改动: 1.去掉了font-awesome图标,上级菜单右边的箭头是自己用css写的,具体参考<css三角箭头>. 2.去掉了初始化 ...
- html自定义垂直导航菜单(加强版--自定义传入menu参数,支持JSONArray、JSArray、JSONObject、JSObject)
在上一篇中我简单写了个html自定义垂直导航菜单,缺点很明显,里面的数据是固定死的,不能动态更改数据. 这里我重写了一个修改版的垂直二级导航菜单,将原先的menuBox.init(config);修改 ...
随机推荐
- POI设置边框
在做一个电子表格时,边框的设置有时是必不可少的.这一节就来介绍边框,设置时,可以指定边框的位置,边框的种类,边框的顔色. 首先是边框的位置和种类.对单元格设置边框时,有上下左右位置之分,所以POI也准 ...
- eclipse SDK更新管理器安装插件
1.在Eclipse的主菜单,点击help,选择Install New Software 2.Work with: Indigo - http://download.eclipse.org/relea ...
- unity HideInInspector与SerializeField
[HideInInspector]表示将原本显示在面板上的序列化值隐藏起来. [SerializeField]表示将原本不会被序列化的私有变量和保护变量可以序列化,这么他们在下次读取时,就是你上次赋值 ...
- Linux常用命令-入门
linux 开源安全性高 linux 和 windows 1.同时登陆多用户 2.安全 3.linux没有盘符的概念 /. / root 根目录 4.linux的文件没有扩展名 ...
- 在fortran下进行openmp并行计算编程
最近写水动力的程序,体系太大,必须用并行才能算的动,无奈只好找了并行编程的资料学习了.我想我没有必要在博客里开一个什么并行编程的教程之类,因为网上到处都是,我就随手记点重要的笔记吧.这里主要是open ...
- Iphone H5上传照片被旋转
最近做项目发现在Iphone下,我们上传图片都会被翻转,最后查阅资料发现,的确是IOS的问题 不说过程,直接解决方法 iOS下,html方式使用<input type="file&qu ...
- 接口测试从未如此简单 - Postman (Chrome插件)【转】
一个非常有力的Http Client工具用来测试Web服务的, 我这里来介绍如何用它测试restful web service 注:转载请注明出处http://www.cnblogs.com/wade ...
- c语言学习感想
接触c语言已经2个多月了,在这段期间按时的完成了作业,上课能够较好的听讲,因此我获得了老师奖励的小黄衫. 同时,希望自己能够学好c语言! 学习感受与心得 因为兴趣,选择了计算机这专业,我从遥远的南方来 ...
- Java高级之内存模型分析
博客出自:http://blog.csdn.net/liuxian13183,转载注明出处! All Rights Reserved ! 下文是博主感悟,请带着怀疑性的态度阅读! 需要了解基本变量所占 ...
- AMQP协议
当前各种应用大量使用异步消息模型,并随之产生众多消息中间件产品及协议,标准的不一致使应用与中间件之间的耦合限制产品的选择,并增加维护成本. AMQP是一个提供统一消息服务的应用层标准协议,基于此协议的 ...