【问题标题】:UIBarButtonItem on navigation bar with UIBarButtonItemStyleDone style doesn't show in blue color具有 UIBarButtonItemStyleDone 样式的导航栏上的 UIBarButtonItem 不显示为蓝色
【发布时间】:2011-12-26 23:05:53
【问题描述】:

我在导航栏上有一个完成按钮,我想让它显示为蓝色。但只是做以下似乎无济于事。我在这里想念什么?我知道如果导航栏为黑色,按钮将自动显示为蓝色,但我不希望此视图控制器上的导航栏颜色为黑色。

- (UIBarButtonItem *)doneButton {
    UIBarButtonItem *doneButton = [[[UIBarButtonItem alloc] initWithTitle:@"Done" 
                                                                    style:UIBarButtonItemStyleDone 
                                                                   target:self 
                                                                   action:@selector(done:)] autorelease];

    return doneButton;
}

【问题讨论】:

    标签: iphone navigationbar uibarbuttonitemstyle


    【解决方案1】:

    在 iOS5 之前,更改 NavigationBar 和 BarItems 外观的组合并非易事。

    标准方式是继承 NavigationBar。这个漂亮的sample code 可能会有所帮助,即使不是直接的。

    在 iOS5 中,您可以使用“外观代理”。不错的教程是here

    【讨论】:

      【解决方案2】:

      您不需要定义自己的完成按钮。只要它被称为“完成”,您就可以使用预定义的 barbuttonsystemitemdone:

         [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone Target:...
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-12-27
        • 1970-01-01
        • 2021-07-25
        相关资源
        最近更新 更多