【问题标题】:UINavigationBar Bottom Separator Line ColorUINavigationBar 底部分隔线颜色
【发布时间】:2010-11-28 16:02:27
【问题描述】:

如何更改分隔导航栏和视图的线条颜色? 例如 flickr 将其更改为灰色 (http://www.geardiary.com/wp-content/uploads/2009/09/Screen-shot-2009-09-08-at-8.00.06-AM.png)

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

提前感谢您的帮助, 妮可

【问题讨论】:

    标签: iphone iphone-sdk-3.0 uinavigationcontroller uinavigationbar


    【解决方案1】:

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

    #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 像素高的彩色条(在顶部现有的工具栏)通过这样做:

    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];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-05
      • 1970-01-01
      • 2013-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-25
      相关资源
      最近更新 更多