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);修改 ...
随机推荐
- 【转】Html页面结构范例
原文地址:http://www.51testing.com/html/38/225738-220986.html · HTML · HEAD · LINK ... CSS files required ...
- java.lang.NoSuchMethodException: org.apache.catalina.deploy.WebXml addServlet的解决方案
tomcat7启动后出现:java.lang.NoSuchMethodException: org.apache.catalina.deploy.WebXml addServlet这个问题. 并且访问 ...
- 转载:C/C++源代码到可执行程序的过程详解
C/C++源代码到可执行程序的过程详解 编译,编译程序读取源程序(字符流),对之进行词法和语法的分析,将高级语言指令转换为功能等效的汇编代码,再由汇编程序转换为机器语言,并且按照操作系统对可执行文件格 ...
- 大话数据结构(五)(java程序)——顺序存储结构的插入与删除
获得元素操作 对于线性表的顺序存储结构来说,我们要实现getElement操作,即将线性表的第i个位置元素返回即可 插入操作 插入算法思路: 1.如果插入位置不合理,抛出异常 2.如果插入表的长度大于 ...
- linux C gcc -lm
使用math.h中声明的库函数还有一点特殊之处,gcc命令行必须加-lm选项,因为数学函数位于libm.so库文件中(这些库文件通常位于/lib目录下),-lm选项告诉编译器,我们程序中用到的数学函数 ...
- php mysql 事务处理
MYSQL 的事务处理主要有两种方法. 1 .用 begin,rollback,commit 来实现 begin 开始一个事务 rollback 事务回滚 commit 事务确认 2 .直接用 ...
- java 开发, jdk 1.6 官方下载地址
在oracle官方网站默认下载的jdk是最新的,目前正式版是1.8. 但有些项目要求是1.6的jdk,费了九牛二虎之力终于找到了1.6的官方版本,链接如下: http://www.oracle.com ...
- 在HCI层看从inquiry的整个过程
一.概述 在windows下寻找远端蓝牙设备,从最开始的inquiry寻找设备,到连接设备,到最后配对完成,整个HCI层所发的command和event以及Data包可以反应整个蓝牙的inqui ...
- 【翻译】How To Tango With Django 1.5.4 第一章
1.概览 这本书的目的就是为了给你提供Django实战开发的指导,这本书主要是为学生设计的,它提供了开发并运行第一个web应用程序的详细的指导步骤,并且指导你怎么将它发布到web服务器上. 本书就是为 ...
- Vmware安装与VMware下Linux系统安装
源文件地址:http://www.cnblogs.com/lclq/p/5619271.html 1.下载安装VMware,我安装的是VMware 12.VMware从11开始不再支持32位系统,32 ...