iPhone 导航栏标题颜色
来源:互联网 发布:javascript项目实战pdf 编辑:程序博客网 时间:2024/06/08 10:09
BY Steven Fisher
You need to use a UILabel as the titleView of the navigationItem.
The label should:
Have a clear background color (label.backgroundColor = [UIColor clearColor]).
Use bold 20pt system font (label.font = [UIFont boldSystemFontOfSize: 20.0f]).
Have a shadow of black with 50% alpha (label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5]).
You'll want to set the text alignment to centered as well (label.textAlignment = UITextAlignmentCenter).
Set the label text color to be whatever custom color you'd like. You do want a color that doesn't cause the text to blend into shadow, which would be difficult to read.
I worked this out through trial and error, but the values I came up with are ultimately too simple for them not to be what Apple picked. :)
If you want to verify this, drop this code into initWithNibName:bundle: in PageThreeViewController.m of Apple's NavBar sample. This will replace the text with a yellow label. This should be indistinguishable from the original produced by Apple's code, except for the color.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
// this will appear as the title in the navigation bar
CGRect frame = CGRectMake(0, 0, 400, 44);
UILabel *label = [[[UILabel alloc] initWithFrame:frame] autorelease];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont boldSystemFontOfSize:20.0];
label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor yellowColor];
self.navigationItem.titleView = label;
label.text = NSLocalizedString(@"PageThreeTitle", @"");
}
return self;
}
(As an aside, I've actually searched for an answer to this problem myself in the months since I first posted it. Imagine my surprise when it was my answer! That's part of why I've come back to clean it up a little...)
- iPhone 导航栏标题颜色
- 导航栏标题颜色
- 导航栏标题颜色设置
- 设置导航栏标题颜色
- IOS改变导航栏标题颜色
- Swift:设置导航栏背景图,标题颜色
- iOS 导航栏标题文字颜色渐变
- ios修改导航栏标题字体颜色
- 设置导航栏标题,字体颜色,大小 背景颜色 等
- 在 iPhone 应用的导航栏添加自定义标题
- 用系统导航控制器改变navigationItem的标题颜色和导航栏颜色
- Android 滑动改变标题/栏导航栏颜色、透明度
- 自定义默认生成的导航栏 标题 颜色 返回按钮
- ios中怎么修改导航栏标题颜色
- iOS 导航栏标题字体的颜色和大小
- iOS导航栏标题字体的颜色字体的大小
- 修改系统导航栏背景色和标题颜色
- iOS-设置navigation导航栏标题的颜色
- 搭建eclips+QT环境备忘录
- eclipse国际化插件安装测试
- 好用的背投广告代码
- Linux C函数小总结
- 查看Linux内核版本的命令 .
- iPhone 导航栏标题颜色
- MyEclipse调试
- Android 线程通信
- sql 字符串相加
- 语义网之--RDF概述
- 让你的代码变的更加健壮(Making your C++ code robust)
- CEDET使用
- VC6下Release版工程增加调试信息遇到的问题和解决的方法
- html表格上方的标题怎么相对表格居中