UINavigationItem setTint Bug?

时间:2015-11-27 08:33:49

标签: ios uibarbuttonitem

我认为这是苹果改变色调颜色的方式的错误:

这是我正在使用的代码:

self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(dismiss)];
self.navigationItem.leftBarButtonItem.tintColor = [UIColor whiteColor];

以后,按下按钮:

[UIView animateWithDuration:1 animations:^{
    self.navigationItem.leftBarButtonItem.tintColor = nil;
}];

无论我放在哪种颜色,效果都一样。

The undesired effect

1 个答案:

答案 0 :(得分:1)

您是否尝试过为不同的状态设置颜色?

[[theNavigationBar.subviews objectAtIndex:1] setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
[[theNavigationBar.subviews objectAtIndex:2] setTitleColor:[UIColor redColor] forState:UIControlStateNormal];