【问题标题】:How can I adjust the highlight color of my UIBarButtonItem?如何调整 UIBarButtonItem 的突出显示颜色?
【发布时间】:2012-01-24 00:19:26
【问题描述】:

我正在使用外观代理来全局调整我的颜色设置:

//Setup custom appearances
    if ([UINavigationBar respondsToSelector:@selector(appearance)]) {
        [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"header"] forBarMetrics:UIBarMetricsDefault];
        [[UINavigationBar appearance] setTintColor:[UIColor colorWithRed:96.0/255.0 green:13.0/255.0 blue:11.0/255.0 alpha:1.0]];
        [[UIBarButtonItem appearance] setTintColor:[UIColor colorWithRed:96.0/255.0 green:13.0/255.0 blue:11.0/255.0 alpha:1.0]];
        //rgb: 96, 13, 11
        //[[UIToolbar appearance] setBackgroundImage:[UIImage imageNamed:@"header"] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
        [[UIToolbar appearance] setTintColor:[UIColor blackColor]];
    }

这很好用,但是当我点击 UINavigationbar 中的 UIBarButtonItem 时,它会将颜色变为黑色。如何确保突出显示的状态不是黑色?

【问题讨论】:

标签: iphone objective-c cocoa-touch uikit uibarbuttonitem


【解决方案1】:

最后一行是:

[[UIToolbar appearance] setTintColor:[UIColor blackColor]];

也许还可以?

【讨论】:

  • 即使我删除该行,我的 UIBarButtonItem 也是黑色的(顺便说一句,它们在我的 UINavigationController 中)
  • 例如,如果将其更改为 redColor 会发生什么?
【解决方案2】:

看看这个:UIBarButtonItem with color?

确保您导入“QuartzCore/QuartzCore.h”以访问 UIView 的图层属性。要导入它,您需要将 CoreGraphics 框架添加到您的项目中。

【讨论】:

    猜你喜欢
    • 2015-11-18
    • 2013-10-19
    • 1970-01-01
    • 1970-01-01
    • 2011-02-02
    • 1970-01-01
    • 2020-03-24
    • 2011-12-09
    • 2012-03-27
    相关资源
    最近更新 更多