NavigationBar的简单设置
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的简单设置的更多相关文章
- 【配置】检测到在集成的托管管道模式下不适用的ASP.NET设置的解决方法(非简单设置为【经典】模式)。
× 检测到在集成的托管管道模式下不适用的ASP.NET设置的解决方法(非简单设置为[经典]模式). 我们将ASP.NET程序从IIS6移植到IIS7,可能运行提示以下错误: HTTP 错误 5 ...
- EditPlus开发Python的简单设置
EditPlus是一个功能强大的编辑器,这里介绍用它来开发Python程序所需要的简单设置. 环境:win7 1.设置Python语法缩进: [1]工具-->设置用户自定义工具 [2]在分类面板 ...
- Android课程---Android Studio简单设置
Android Studio 简单设置 界面设置 默认的 Android Studio 为灰色界面,可以选择使用炫酷的黑色界面.Settings-->Appearance-->Theme, ...
- Kali-linux安装之后的简单设置
1.更新软件源:修改sources.list文件:leafpad /etc/apt/sources.list然后选择添加以下适合自己较快的源(可自由选择,不一定要全部): #官方源deb http:/ ...
- 【转】Android Studio简单设置
原文网址:http://ask.android-studio.org/?/article/14 Android Studio 简单设置 界面设置 默认的 Android Studio 为灰色界面,可以 ...
- Android Studio简单设置(转)
Android Studio 简单设置 界面设置 默认的 Android Studio 为灰色界面,可以选择使用炫酷的黑色界面.Settings --> Appearance --> Th ...
- IIS 7.5 使用URL Rewrite模块简单设置网页跳转
原文 IIS 7.5 使用URL Rewrite模块简单设置网页跳转 我们都知道Apache可以在配置文件里方便的设置针对网页或网站的rewrite,但是最近接手了一组IIS服务器,发现这货简单的没有 ...
- (求租仓库)navigationController .navigationBar 的属性设置
需要做成的效果如下图的
- mysql加速导入数据的简单设置
mysql加速导入数据的简单设置 # 修改前查询参数值 show variables like 'foreign_key_checks'; show variables like 'unique_ch ...
随机推荐
- Java基础知识强化之IO流笔记79:NIO之 SocketChannel
1. Java NIO中的SocketChannel是一个连接到TCP网络套接字的通道.可以通过以下2种方式创建SocketChannel: 打开一个SocketChannel并连接到互联网上的某台服 ...
- 关于Django中的表单验证
ModelForm 和 普通的Form 都可以做表单验证 对于ModelForm如果只是想验证其中一部分model中的field,可以指定:内部类Meta的fields元素: fields = ('x ...
- UIPickerView 简单操作和实际应用
1.UIPickerView 选择指示器控件 //选择器的初始化 UIPickerView * pickerView = [[UIPickerView alloc] initWithFrame:CGR ...
- Oracle基础(四) 用户管理
一.用户 当创建一个数据实例时,Oracle会创建一些默认的数据库用户,如SYS,SYSTEM和SCOTT等用户.SYS和SYSTEM用户都是ORACLE的系统用户.而Scott用户是Oracle数据 ...
- VMware系统运维(十一)部署虚拟化桌面 Horizon View 5.2 HTML ACCESS安装
如果你希望在浏览器上面能够连接到用户桌面,那么HTML ACCESS是必须安装的,下面开始安装. 1.点击红框文件 2.打开安装向导,点击"下一步" 3.接受协议,点击" ...
- WPF全球化与本地化 (二)
Visual Baml Visual Locbaml is a free and open-source software to simplify the task of WPF applicatio ...
- HttpServletResponse接口
public interface HttpServletResponse extends ServletResponse 描述一个返回到客户端的HTTP回应.这个接口允许Servlet程序员利用HTT ...
- Android ViewPager的简单实现
研究了两天ViewPager,看了几篇网上的帖子,但总的来说看得一头雾水,理不清头绪,偶然发现了一篇简单易懂的帖子,讲的调理比较清晰,原文链接附在文后. 在本例中使用ViewPager + Fra ...
- 关于近期需要学习sqlserver2008
在胜利油田物探院借了一本书叫做 sqlserver2008宝典 第二版,但是看不下去 下面打算直接安装数据库上手了,边练边学
- 推荐5 款WordPress主题后台选项开发框架
在开发WordPress 主题的时候,借用成熟的WordPress 主题后台选项开发框架可以为我们省下不少功夫.相信你接触过不少国人做的所谓“原创”主题,一看后台都是千篇一律的界面(连CSS 都懒得改 ...