---
title: "自定义导航栏"
author: "刺骨的夜"
date: "2015-01-12T16:53:41Z"
tags: []
categories: ["编程语言"]
slug: "untitled"
draft: false
lastmod: "2015-01-12T16:53:41Z"
id: 2175115
url: "https://lanxs.iteye.com/blog/2175115"
---

一、全局宏定义

       //系统版本号

#define SYS\_VERSION \[\[\[UIDevice currentDevice] systemVersion] floatValue]

//颜色

#define UICOLORFROMRGB(rgbValue) \[UIColor colorWithRed:((float)((rgbValue & 0xFF0000) &gt;&gt; 16))/255.0 green:((float)((rgbValue & 0xFF00) &gt;&gt; 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

// 程序可用的rect

#define SCREEN\_HEIGHT \[\[UIScreen mainScreen] bounds].size.height

 

#define SCREEN\_WIDTH \[\[UIScreen mainScreen] bounds].size.width

 

调用颜色设置的时候：UICOLORFROMRGB(0x05406c)  需要加上0x

 

 

二、在AppDelegate中  把主界面添加到导航之后  需把系统的导航栏隐藏    self.navigationController.navigationBarHidden = YES;  创建类别的时候 类继承 NavigatorViewController  在子类中可以自由重写导航的左右两边按钮事件   子类里面创建控件的轴坐标  需要从 self.validRect.origin.y 开始