ami*_*jaj 1 iphone uitoolbar uicolor uitoolbaritem ios
在我的应用程序中,我现在对以前使用轻型键盘的所有UITextField使用“深色”外观的键盘。
在文本字段之一的键盘上方,我创建了一个自定义UIToolbar,其中包含一些按钮,允许用户选择键盘上方的选项之一。
这似乎比实际需要的要难得多,但是我试图使UIToolBar变暗而不是变亮,无论我如何尝试,工具栏始终是白色的,我似乎只能更改按钮的颜色。工具栏,而不是工具栏本身。
工具栏是用以下代码创建的:
UIToolbar *alertToolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0.0f, 0.0f,
self.view.window.frame.size.width, 44.0f)];
alertToolBar.backgroundColor = [UIColor blackColor];
//alertToolBar.tintColor = [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:1.0f];
alertToolBar.translucent = NO;
alertToolBar.items = @[ [[UIBarButtonItem alloc] initWithTitle:@" GBP"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(barButtonAddText:)],
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil],
[[UIBarButtonItem alloc] initWithTitle:@" USD"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(barButtonAddText:)],
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil],
[[UIBarButtonItem alloc] initWithTitle:@" EUR"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(barButtonAddText:)],
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil],
self.itemTextField.inputAccessoryView = alertToolBar;
Run Code Online (Sandbox Code Playgroud)
我已经使用上面(//alertToolBar.tintColor = [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:1.0f];)注释掉的代码进行了尝试,并且条形图始终保持白色,但是只有“按钮”会改变颜色。
如何将整个工具栏更改为黑色?
任何帮助,将不胜感激!
我猜您正在使用iOS 7.0 SDK,因此在这种情况下,barTint不再适用于此。
在这种情况下,您将需要使用barTintColor。
苹果的文档:
酒吧的tintColor行为在iOS 7.0上已更改。它不再影响栏的背景,并且行为与添加到UIView的tintColor属性相同。要着色栏的背景,请使用-barTintColor。
在这种情况下应为:
alertToolBar.barTintColor = [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:1.0f];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2755 次 |
| 最近记录: |