self.navigationItem.leftBarButtonItem.tintColor = [UIColor whiteColor];
我已经完成了上面的工作,但它不起作用。颜色仍然和背景颜色一样!
答案 0 :(得分:3)
创建按钮并替换
UIBarButtonItem *leftBarButton = [[UIBarButtonItem alloc] initWithCustomView:self.leftBarButton];
self.navigationItem.leftBarButtonItem = leftBarButton;
或
+ (UIBarButtonItem*)itemWithNormalImage:(UIImage*)normalImage
pressedImage:(UIImage*)pressedImage
target:(id)target
action:(SEL)action
{
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:normalImage
forState:UIControlStateNormal];
[button setImage:pressedImage
forState:UIControlStateSelected];
[button setImage:pressedImage
forState:UIControlStateHighlighted];
button.frame = CGRectMake(0, 0, normalImage.size.width, normalImage.size.height);
[button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem* item=[[UIBarButtonItem alloc] initWithCustomView:button];
return item;
}
文字颜色:
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"done" style:UIBarButtonItemStyleBordered target:self action:nil];
[item setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]} forState:UIControlStateNormal];
self.navigationItem.leftBarButtonItems = @[item];