我想更改键盘toobar
的标题颜色,即(提交按钮),另一种是如何为键盘工具栏添加图像。 TIA
UIToolbar *keyboardToolbar = [[UIToolbar alloc] init];
[keyboardToolbar sizeToFit];
keyboardToolbar.translucent=NO; //if you want it.
keyboardToolbar.barTintColor = [UIColor lightGrayColor];
_txtCommentView.inputAccessoryView = keyboardToolbar;
keyboardToolbar.items = [NSArray arrayWithObjects:
[[UIBarButtonItem alloc]initWithTitle:@"Submit" style:UIBarButtonItemStyleBordered target:self action:@selector(submitClicked:)],
nil];
答案 0 :(得分:1)
尝试以下代码并根据您的要求进行更改:
UIToolbar *keyboardToolbar = [[UIToolbar alloc] init];
[keyboardToolbar sizeToFit];
keyboardToolbar.translucent=NO; //if you want it.
keyboardToolbar.barTintColor = [UIColor lightGrayColor];
_txtCommentView.inputAccessoryView = keyboardToolbar;
UIBarButtonItem *submit = [[UIBarButtonItem alloc] initWithTitle:@"Submit"
style:UIBarButtonItemStyleBordered
target:self action:@selector(submitClicked:)];
//Change submit button attributes here as you want
[submit setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont fontWithName:@"Helvetica-Bold" size:18.0], NSFontAttributeName,
[UIColor whiteColor], NSForegroundColorAttributeName,
nil] forState:UIControlStateNormal];
keyboardToolbar.items = [NSArray arrayWithObjects:submit, nil];
答案 1 :(得分:0)
如果要更改整个应用程序工具栏中的更改,请使用
[UIToolbar appearance].tintColor = [UIColor redColor];
[UIToolbar appearance].barTintColor = [UIColor greenColor];
您也可以使用以下代码进行更改:
NSDictionary *attributes = @{
NSForegroundColorAttributeName: [UIColor colorWithRed:220.0/255.0 green:104.0/255.0 blue:1.0/255.0 alpha:1.0],
NSFontAttributeName: [UIFont fontWithName:@"Arial" size:16.0]
};
[[UIBarButtonItem appearance] setTitleTextAttributes:attributes forState:UIControlStateNormal];