这是一个非常简单的问题,我真的找不到答案!
好吧,默认情况下,如果我设置 UIToolbar 的 tintColor,UIBarButtonItem 的颜色将是相同的。
我只想更改 UIBarButtonItems 的颜色并更改其文本的颜色。
有没有人知道如何做到这一点?
我真的不敢相信它是如此复杂,真的......更改 UIButton 属性如此简单,我不明白为什么 UIBarButtonItem 不一样......
非常感谢!
这是一个非常简单的问题,我真的找不到答案!
好吧,默认情况下,如果我设置 UIToolbar 的 tintColor,UIBarButtonItem 的颜色将是相同的。
我只想更改 UIBarButtonItems 的颜色并更改其文本的颜色。
有没有人知道如何做到这一点?
我真的不敢相信它是如此复杂,真的......更改 UIButton 属性如此简单,我不明白为什么 UIBarButtonItem 不一样......
非常感谢!
不确定您是否找到了答案。这是我的做法:
UIImage *buttonImage = [[UIImage imageNamed:@"btnGreen.png"] stretchableImageWithLeftCapWidth:10 topCapHeight:0];
UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
[doneButton setBackgroundImage:buttonImage forState:UIControlStateNormal];
[doneButton setTitle:@"Done" forState:UIControlStateNormal];
[doneButton addTarget:self action:@selector(saveDateEdit:) forControlEvents:UIControlEventTouchUpInside];
[doneButton.titleLabel setFont:[UIFont boldSystemFontOfSize:13]];
doneButton.frame = CGRectMake(0.0, 0.0, 50, 30);
btnDone = [[UIBarButtonItem alloc] initWithCustomView:doneButton];
[doneButton release];