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. 升级树莓派archlinux系统到新sd卡

    由于之前把树莓派系统安装在4gb的sd卡上,随着系统的更新及安装了一大堆软件包之后,系统提示空间不足了.网上搜索了下,把所有数据迁移到新的sd卡上还是比较简单的. 克隆sd卡: 1,关闭树莓派电源,取 ...

  2. [Windows] Visual Studio 2010 快捷键大全

    Ctrl+E,D ----格式化全部代码 Ctrl+E,F ----格式化选中的代码 CTRL + SHIFT + B生成解决方案 CTRL + F7 生成编译 CTRL + O 打开文件 CTRL ...

  3. 【Mood-18】github 使用指南

    windows下使用教程: http://www.cnblogs.com/dongdong230/p/4211221.html repository not found error问题解决(需确定gi ...

  4. 【Android车载系统 News | Tech 4】知乎--车载话题链接

    知乎--车联网话题http://www.zhihu.com/topic/19646713

  5. SQL Server 2008数据类型

    在创建表时,必须为表中的每列指派一种数据类型. 今天在研究二进制存储图片时候竟然不知道image类型就是二进制类型?!所有就搜集了sql中的各种数据类型汇总,成功在于点滴积累. 1. 字符数据类型 数 ...

  6. Kinect For Windows V2开发日志八:侦测、追踪人体骨架

    简介 Kinect一个很强大的功能就是它可以侦测到人体的骨骼信息并追踪,在Kinect V2的SDK 2.0中,它最多可以同时获取到6个人.每个人25个关节点的信息,并且通过深度摄像头,可以同时获取到 ...

  7. 解决$_REQUEST['name']Undefined问题

    最近按照w3school一步一步学php,当学到$_REQUEST的时候,依旧按照w3cshool所提供的代码自己手敲了一遍,代码如下: <html> <body> <f ...

  8. table表格实现点击修改 PHP同步数据库 排序

    最近几天在做一个网站,牵扯到一个导航管理的功能!领导说不用作,可是由于自己自作主张,搞了1天的功能.领导说这个导航管理就是不用做!容易牵扯出好多问题来!估摸是客户小的原因! 没办法就把我1天的劳动荒废 ...

  9. centOS6.5x64简单的安装openfire

    yum install java libldb.i686 mysql-server mysql-connector-java 创建数据库 create database openfire defaul ...

  10. git 基本使用

    简单几步操作让你在终端下用git实现文件的上传. 一.克隆项目    在工作中,常见的情景都是远程库已经建好了,需要大家把代码拉下来,共同协作开发.本文所有操作均在终端下进行.    //克隆一个本地 ...