更改键盘工具栏的标题颜色 objective-C
Change the title color of keyboard toolbar objective-C
我想更改键盘的标题颜色 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];
尝试以下代码并根据您的要求进行更改:
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];
如果您想更改整个应用程序工具栏中的更改,请使用
[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];
我想更改键盘的标题颜色 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];
尝试以下代码并根据您的要求进行更改:
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];
如果您想更改整个应用程序工具栏中的更改,请使用
[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];