Ryz*_*ond 2 iphone objective-c ios4 ios
我知道您可以通过调用SetTitle方法navigationItem来更改导航项的标题,如下所示:
[[ViewController navigationItem] setTitle:@"Hello World"];
Run Code Online (Sandbox Code Playgroud)
但是,我想做更多然后只需更改导航项的文本,我想改变颜色和字体样式.
是否有任何功能可以让您更改导航栏标题的颜色?
Cla*_*nce 12
您只需在viewdidload方法中添加和修改以下代码即可.或者您甚至可以在导航栏上放置图像
if ([[UINavigationBar class]respondsToSelector:@selector(appearance)]) {
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"image.png"] forBarMetrics:UIBarMetricsDefault];
}
[[UINavigationBar appearance] setTitleTextAttributes:@{
UITextAttributeTextColor : [UIColor whiteColor],
UITextAttributeTextShadowColor : [UIColor blackColor],
UITextAttributeTextShadowOffset : [NSValue valueWithUIOffset:UIOffsetMake(1, 0)],
UITextAttributeFont : [UIFont fontWithName:@"System" size:25.0]
}];
Run Code Online (Sandbox Code Playgroud)
希望这有帮助
| 归档时间: |
|
| 查看次数: |
4497 次 |
| 最近记录: |