UINavigationBar底部分隔线颜色 [英] UINavigationBar Bottom Separator Line Color

查看:323
本文介绍了UINavigationBar底部分隔线颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改分隔导航栏和视图的线条的颜色? 例如flickr将其更改为灰色(

How can I change the line's color that separates the navigation bar and the view? For instance flickr changed it to gray (http://www.geardiary.com/wp-content/uploads/2009/09/Screen-shot-2009-09-08-at-8.00.06-AM.png)

默认情况下,我的总是黑...

By default mine is always black...

预先感谢您的帮助, 尼科

Thanks in advance for your help, nico

推荐答案

他们使用了自定义的底部栏,而不是Apple提供的底部栏.我不知道您的设置,但是如果您可以根据需要创建或绘制自己的自定义视图(可以执行此操作),并在其上粘贴按钮(也可以执行此操作),那么您将拥有一个工具栏

They used a custom bottom bar and not the Apple provided ones. I dont know your setup, but if you can make or draw your own custom view however you want (you can do this), and stick buttons on it (you can do this too), then you have a toolbar

#define TOOLBAR_HEIGHT 44

CGRect frame = CGRectMake(self.view.bounds.size.height - TOOLBAR_HEIGHT, 0.0, self.view.bounds.size.width, TOOLBAR_HEIGHT);
UIView *customBottomBar = [[UIView alloc] initWithFrame:frame];
[customBottomBar setBackgroundColor: [UIColor grayColor]];

UIButton *button = [[UIButton alloc] initWithFrame:<frame goes here>]
... <button setup>
[customBottomBar addSubview:button];
[button release];

...<more buttons>
...<more buttons>

[self.view addSubview:customBottomBar];
[customBottomBar release];

要回答您的问题,您可以在任何视图中添加所需的内容,因此尽管我所建议的方式是最可定制的,但您可能只想在正确的位置(位于顶部)放置一个1像素高的彩色条即可.现有工具栏),方法是:

And to answer your question, you can add whatever you want to any view, so while the way I just suggest is the most customizable, you might just want to place a 1pixel high colored bar at the right spot (on top of the existing toolbar) by doing this:

CGRect frame = CGRectMake(self.view.bounds.size.height - TOOLBAR_HEIGHT, 0.0, self.view.bounds.size.width, 1);
UIView *customLine = [[UIView alloc] initWithFrame:frame];
[customLine setBackgroundColor: [UIColor grayColor]];
[self.view addSubview:customLine];
[customLine release];

这篇关于UINavigationBar底部分隔线颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆