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. 通过cagradientLayer类封装uiimageview动画色度差

    #import <UIKit/UIKit.h> typedef NS_ENUM(NSInteger, EcolorDirectionType) { EcolorDirectionUp, / ...

  2. NSOperation使用系统提供子类的方法--处理复杂任务

    //创建一个队列 NSOperationQueue *operation=[[NSOperationQueue alloc]init]; //把任务放在NSBlockOperation里面 NSBlo ...

  3. 初学者学习javascript语言应注意的那几点

    javascript在书写时应注意得那四点: 1)大小写敏感: 2)javascript是弱类型语言,声明变量是应全部使用var(因为javascript是弱类型语言): 3)字符串在定义时使用单引号 ...

  4. 【Shell脚本学习19】Shell while循环

    while循环用于不断执行一系列命令,也用于从输入文件中读取数据:命令通常为测试条件.其格式为: while command do    Statement(s) to be executed if ...

  5. Swift 2.0学习

    前几天在苹果官方文档学习iOS9 3D Touch的时候,发现苹果关于3D Touch的smaple code,竟然是用Swift语法写的,并且根本没有OC版本的. 看来学习Swift语法是势在必行了 ...

  6. 重构3-Pull Up Method(方法上移)

    上移方法(Pull Up Method)重构是将方法向继承链上层迁移的过程.用于一个方法被多个实现者使用时 public abstract class Vehicle { // other metho ...

  7. Float精度 在JS的解决方法

    最近在做一个工资核算的系统,所有的运算全部在前台进行,因此用了的是JS来做. 做完以后,经手工核算,发现一个奇怪的问题.就是JS算出来的结果跟用计算器算出来的结果有差距. 想了很久,也没有想出问题出在 ...

  8. 【前端JS、后台C#】编码解码。

    最近做项目,出现中文乱码的问题,特地研究一下. GB2312,指的是中文 UTF8,指的是国标,包含中文.英文. 但是通过JQuery.ajax的Get.Post,如果直接传递中文或者特殊字符的特使字 ...

  9. Chrome隐身模式有什么用

    最近发布的Chrome浏览器,小编发现有一个个“隐身窗口”功能,那么这是什么功能呢?原来这是Chrome隐身模式!那么这个隐身模式有什么功能呢? Chrome隐身模式有什么用? 从官方的介绍来看,“隐 ...

  10. sql导出查询数据

    from sysobjects where name ='proc_exporttb' and xtype ='P') drop proc proc_exporttb go create proc p ...