HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iphone – 如何更改导航栏上的UIBarButtonItem的字体颜色/文本颜色大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_197_2@
我按照如下方式在导航栏中添加一个条形按钮

UIBarButtonItem *cancel = [[UIBarButtonItem alloc] initWithtitle:@"CANCEL" style:UIBarButtonItemStyleBordered target:self action:@SELEctor(goToPrevIoUsView)];
    self.navigationItem.leftBarButtonItem = cancel;

现在我想在RED Color中显示文本“CANCEL”。

我的意思是我需要更改按钮上的文本按钮,但不是按钮的色调。

怎么做?

@H_197_2@

解决方法

另一种方法是:

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setBACkgroundImage:[UIImage imagenamed:@"delete.png"] forState:UIControlStateNormal];
[button settitle:@"delete" forState:UIControlStateNormal];
 button.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:12.0f];
[button.layer setCornerRadius:4.0f];
[button.layer setMasksToBounds:YES];
[button.layer setBorderWidth:1.0f];
[button.layer setBorderColor: [[UIColor grayColor] CGColor]];
button.frame=CGRectMake(0.0,100.0,60.0,30.0);
[button addTarget:self action:@SELEctor(batchDelete)  forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem* deleteItem = [[UIBarButtonItem alloc] initWithCustomView:button];
@H_197_2@ @H_197_2@
@H_197_2@
@H_197_2@

大佬总结

以上是大佬教程为你收集整理的iphone – 如何更改导航栏上的UIBarButtonItem的字体颜色/文本颜色全部内容,希望文章能够帮你解决iphone – 如何更改导航栏上的UIBarButtonItem的字体颜色/文本颜色所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。