Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIToolbar tintColor没有效果_Ios_Objective C_Uibarbuttonitem_Uitoolbar_Uicolor - Fatal编程技术网

Ios UIToolbar tintColor没有效果

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

我有一个时区选择器,它为iPhone和iPod之间的“完成”按钮显示不同的颜色:

iPhone

iPod

代码如下:

    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

谁能告诉我:

  • 为什么iPhone和iPod处理这些代码的方式不同

  • 为什么设置“toolbar”和“doneButton”的tintColor属性没有任何效果

  • 如何使iPod显示屏与iPhone匹配


  • 尝试将工具栏barStyle设置为UIBarStyleBlackTransparent。[工具栏设置样式:UIBarStyleBlack半透明];没有效果。还有其他想法吗?删除bar style并选中itTry将工具栏barStyle设置为UIBarStyleBlack半透明。[工具栏设置样式:UIBarStyleBlack半透明];没有效果。还有其他想法吗?删除酒吧风格并检查它
    toolbar.barTintColor = [UIColor greenColor];