Ios UIToolbar tintColor没有效果
我有一个时区选择器,它为iPhone和iPod之间的“完成”按钮显示不同的颜色: iPhone: iPod: 代码如下:Ios UIToolbar tintColor没有效果,ios,objective-c,uibarbuttonitem,uitoolbar,uicolor,Ios,Objective C,Uibarbuttonitem,Uitoolbar,Uicolor,我有一个时区选择器,它为iPhone和iPod之间的“完成”按钮显示不同的颜色: iPhone: iPod: 代码如下: UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, 44)]; [toolbar setBarStyle:UIBarStyleBlackOpaque]; toolbar.barTintColor = [UIColo
UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, 44)];
[toolbar setBarStyle:UIBarStyleBlackOpaque];
toolbar.barTintColor = [UIColor darkAppColor];
toolbar.translucent = NO;
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:nil];
// doneButton.tintColor = [UIColor redColor]; // this has no effect
// toolbar.tintColor = [UIColor redColor]; // this has no effect
UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
toolbar.items = @[flexibleSpace, doneButton];
AppConstants.m
@implementation UIColor
...
+ (UIColor *)darkAppColor
{
return [UIColor colorWithHex:0x054e85];
}
...
@end
我希望iPod的屏幕看起来像iPhone(没有淡蓝色的“完成”按钮)。奇怪的是,如果我改变这一行:
toolbar.barTintColor = [UIColor darkAppColor];
到
然后,选择器的整个导航栏(包括“完成”按钮)是统一的(尽管颜色不正确)。正如您可以从上面代码中注释掉的行中看到的,我还尝试更改“Done”按钮和工具栏的tintColor属性,但这似乎没有任何效果
两台设备都运行iOS 10.2
谁能告诉我:
尝试将工具栏barStyle设置为UIBarStyleBlackTransparent。[工具栏设置样式:UIBarStyleBlack半透明];没有效果。还有其他想法吗?删除bar style并选中itTry将工具栏barStyle设置为UIBarStyleBlack半透明。[工具栏设置样式:UIBarStyleBlack半透明];没有效果。还有其他想法吗?删除酒吧风格并检查它
toolbar.barTintColor = [UIColor greenColor];