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 ...
随机推荐
- 控件WebView网页的加载
Android:控件WebView网页的加载 WebView可以使得网页轻松的内嵌到app里,还可以直接跟js相互调用. webview有两个方法:setWebChromeClient 和 setWe ...
- 【Android Studio使用教程4】Android Studio下载
鉴于Android官网上下载很慢,Android Studio等已在网盘分享:Android Studio 网盘下载路径: windows:http://yunpan.cn/cfTszP2wrJxdD ...
- 自定义基本java类-StdDraw.java
/************************************************************************* * Compilation: javac StdD ...
- Flume Spooldir 源的一些问题
Flume Spooldir 源的一些问题 来自:http://blog.xlvector.net/2014-01/flume-spooldir-source-problem/ ( 自己写的插件,数据 ...
- hdu 4403 简单搜索
思路:分等号左边和右边进行搜索 #include<iostream> #include<cstdio> #include<cstring> #include< ...
- 转: android apk 防止反编译技术(1~5连载)
转: android apk 防止反编译技术 做android framework方面的工作将近三年的时间了,现在公司让做一下android apk安全方面的研究,于是最近就在网上找大量的资料来学习. ...
- freeCodeCamp:Diff Two Arrays
比较两个数组,然后返回一个新数组,该数组的元素为两个给定数组中所有独有的数组元素.换言之,返回两个数组的差异. function diff(arr1, arr2) { var newArr = []; ...
- html5+css3第一屏滚屏动画效果
详细内容请点击 在线预览立即下载 html5+css3第一屏滚屏动画效果. 转载自:http://tympanus.net/codrops/2014/05/22/inspiration-for-art ...
- sql深入理解
我们做软件开发的,大部分人都离不开跟数据库打交道,特别是erp开发的,跟数据库打交道更是频繁,存储过程动不动就是上千行,如果数据量大,人员流动大,那么我们还能保证下一段时间系统还能流畅的运行吗?我们还 ...
- c#中进程的使用
C#的Process类的一些用法 更多0 c# 进程 c#之process类相关整理 一.根据进程名获取进程的用户名? 需要添加对 System.Management.dll 的引用 usin ...