http://blog.csdn.net/hufeng825/article/details/7643532#)

.Label属性设置

    titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(, , , )];

    titleLabel.backgroundColor = [UIColor clearColor];//设置Label背景透明

    titleLabel.font = [UIFont boldSystemFontOfSize:];

    titleLabel.textColor = [UIColor colorWithRed:0.0/255.0 green:255.0/255.0 blue:0.0/255.0 alpha:];

    titleLabel.textAlignment = UITextAlignmentCenter;

    titleLabel.text = @"自定义标题";

.button属性设置

    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];

    [button setTitle:@"Button" forState:UIControlStateNormal];

    [button sizeToFit];

.在navigationItem中添加Label

   self.navigationItem.titleView = self.titleLabel;

.创建一个UIBarButtonItem用的方法主要有:

[UIBarButtonItem alloc]initWithTitle:(NSString *) style:(UIBarButtonItemStyle) target:(id) action:(SEL)

[UIBarButtonItem alloc]initWithBarButtonSystemItem:(UIBarButtonSystemItem) target:(id) action:(SEL)

http://blog.csdn.net/hufeng825/article/details/7643532#)

.Label属性设置

    titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(, , , )];

    titleLabel.backgroundColor = [UIColor clearColor];//设置Label背景透明

    titleLabel.font = [UIFont boldSystemFontOfSize:];

    titleLabel.textColor = [UIColor colorWithRed:0.0/255.0 green:255.0/255.0 blue:0.0/255.0 alpha:];

    titleLabel.textAlignment = UITextAlignmentCenter;

    titleLabel.text = @"自定义标题";

.button属性设置

    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];

    [button setTitle:@"Button" forState:UIControlStateNormal];

    [button sizeToFit];

.在navigationItem中添加Label

   self.navigationItem.titleView = self.titleLabel;

.创建一个UIBarButtonItem用的方法主要有:

[UIBarButtonItem alloc]initWithTitle:(NSString *) style:(UIBarButtonItemStyle) target:(id) action:(SEL)

[UIBarButtonItem alloc]initWithBarButtonSystemItem:(UIBarButtonSystemItem) target:(id) action:(SEL)

 .在navigationItem中添加多个右按钮

定义一组button,将buttons放入array,再令rightBarButtonItems(注意有s) = array。

    UIBarButtonItem *button1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:nil];

    UIBarButtonItem *button2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:nil];

    UIBarButtonItem *button3 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:nil];

    UIBarButtonItem *button4 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:nil];

    NSArray *array = [[NSArray alloc] initWithObjects:button1,button2,button3,button4, nil];

    self.navigationItem.rightBarButtonItems = array;

.设置NavigationBar背景颜色

self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:/ green:/ blue:/ alpha:];

.设置NavigationBar背景图片

    UIImage *title_bg = [UIImage imageNamed:@"title_bg"]; //获取图片

    CGSize titleSize = self.navigationController.navigationBar.bounds.size; //获取NavigationBar的位置和大小

    title_bg = [self scaleToSize: title_bg size:titleSize];

    //设置图片大小与NavigationBar相同

    [self.navigationController.navigationBar setBackgroundImage:title_bg forBarMetrics:UIBarMetricsDefault];

    //设置背景

//用于调整图片大小的方法

-(UIImage *) scaleToSize: (UIImage *) img size:(CGSize) size{

    UIGraphicsBeginImageContext(size);

    [img drawInRect:CGRectMake(, , size.width, size.height)];

    UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return scaledImage;

}

.在navigationItem中添加多个右按钮

定义一组button,将buttons放入array,再令rightBarButtonItems(注意有s) = array。

    UIBarButtonItem *button1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:nil];

    UIBarButtonItem *button2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:nil];

    UIBarButtonItem *button3 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:nil];

    UIBarButtonItem *button4 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:nil];

    NSArray *array = [[NSArray alloc] initWithObjects:button1,button2,button3,button4, nil];

    self.navigationItem.rightBarButtonItems = array;

.设置NavigationBar背景颜色

self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:/ green:/ blue:/ alpha:];

.设置NavigationBar背景图片

    UIImage *title_bg = [UIImage imageNamed:@"title_bg"]; //获取图片

    CGSize titleSize = self.navigationController.navigationBar.bounds.size; //获取NavigationBar的位置和大小

    title_bg = [self scaleToSize: title_bg size:titleSize];

    //设置图片大小与NavigationBar相同

    [self.navigationController.navigationBar setBackgroundImage:title_bg forBarMetrics:UIBarMetricsDefault];

    //设置背景

//用于调整图片大小的方法

-(UIImage *) scaleToSize: (UIImage *) img size:(CGSize) size{

    UIGraphicsBeginImageContext(size);

    [img drawInRect:CGRectMake(, , size.width, size.height)];

    UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return scaledImage;

}

NavigationBar的简单设置的更多相关文章

  1. 【配置】检测到在集成的托管管道模式下不适用的ASP.NET设置的解决方法(非简单设置为【经典】模式)。

      ×   检测到在集成的托管管道模式下不适用的ASP.NET设置的解决方法(非简单设置为[经典]模式). 我们将ASP.NET程序从IIS6移植到IIS7,可能运行提示以下错误: HTTP 错误 5 ...

  2. EditPlus开发Python的简单设置

    EditPlus是一个功能强大的编辑器,这里介绍用它来开发Python程序所需要的简单设置. 环境:win7 1.设置Python语法缩进: [1]工具-->设置用户自定义工具 [2]在分类面板 ...

  3. Android课程---Android Studio简单设置

    Android Studio 简单设置 界面设置 默认的 Android Studio 为灰色界面,可以选择使用炫酷的黑色界面.Settings-->Appearance-->Theme, ...

  4. Kali-linux安装之后的简单设置

    1.更新软件源:修改sources.list文件:leafpad /etc/apt/sources.list然后选择添加以下适合自己较快的源(可自由选择,不一定要全部): #官方源deb http:/ ...

  5. 【转】Android Studio简单设置

    原文网址:http://ask.android-studio.org/?/article/14 Android Studio 简单设置 界面设置 默认的 Android Studio 为灰色界面,可以 ...

  6. Android Studio简单设置(转)

    Android Studio 简单设置 界面设置 默认的 Android Studio 为灰色界面,可以选择使用炫酷的黑色界面.Settings --> Appearance --> Th ...

  7. IIS 7.5 使用URL Rewrite模块简单设置网页跳转

    原文 IIS 7.5 使用URL Rewrite模块简单设置网页跳转 我们都知道Apache可以在配置文件里方便的设置针对网页或网站的rewrite,但是最近接手了一组IIS服务器,发现这货简单的没有 ...

  8. (求租仓库)navigationController .navigationBar 的属性设置

    需要做成的效果如下图的

  9. mysql加速导入数据的简单设置

    mysql加速导入数据的简单设置 # 修改前查询参数值 show variables like 'foreign_key_checks'; show variables like 'unique_ch ...

随机推荐

  1. 跨平台轻量级redis、ssdb代理服务器(C++ 11编写)

    dbproxy 是我业余采用C++11编写的跨平台代理服务器(并使用lua和自己的网络库),以扩展系统负载,同时使用多个后端数据库,后端数据库支持redis和ssdb. 需要由用户自己编写lua脚本控 ...

  2. [Java] JSTL格式化时间计算时差

    引入JSLT标签: <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> ...

  3. 菜菜菜鸟学习之JavaWeb 入门1(自己的学习理解,不对之处请大神们多多指教啊)

    一.相关基础知识 1.C/S(Client/Server)架构和B/S(Browser/Server)架构 首先说C/S架构,简单讲其实很常见,类似QQ等需要下载客户端的应用程序就是建立在C/S架构中 ...

  4. Oracle基础(五) 权限管理

    一.数据库权限分类 权限是指用户对某个功能是否具有执行的权利.在Oracle中,权限分为系统权限和对象权限. 1.系统权限 系统规定用户使用数据库的权限.例如创建表空间,创建表,删除表的权利.这些都属 ...

  5. PHP 错误处理机制

    在日常的项目开发过程中,总是会出现一些我们意想不到的异常错误,如果我们对此没有进行相对完善的处理,那么程序看上去也很不专业,也很可能就会成为别人攻击系统的有效信息:有些错误异常会终止脚本执行,这个时候 ...

  6. 关于VIM在Win10下的无意义折腾

    这两天和VIM较上劲了,总结下来其实是极无意义的折腾,浪费了很多宝贵的时间! 事情是这样的,无意中发现vim在Win10的控制台窗口无参数打开时不显示那个“乌干达儿童”的界面(其实就是:intro的内 ...

  7. poj 1698 Alice's Chance 最大流

    题目:给出n部电影的可以在周几拍摄.总天数.期限,问能不能把n部电影接下来. 分析: 对于每部电影连上源点,流量为总天数. 对于每一天建立一个点,连上汇点,流量为为1. 对于每部电影,如果可以在该天拍 ...

  8. Pascal 语言中二维数组:矩阵问题

    [题目]方阵填数:在一个 N*N的方阵中,填入 1,2..... N*N个数,并要求构成如下格式: 图例:10 11 12  1            9  16 13  2            8 ...

  9. 转:实体ToolTip显示XData

    首先要说明,实现方式不是我的原创,其中ToolTip的实现转自这里,然后XData的设置和获取来自Kean的博客,当然我自己也做了点研究,在这里,然后把这两个技术结合起来就是你将要看到的东西. 先上效 ...

  10. 记录android5.0更新踩过的坑

    1. service的注册必须显示注册,不能隐式注册,相关链接http://www.eoeandroid.com/thread-568853-1-1.html 现象:Service Intent mu ...