小编New*_*der的帖子

高亮显示UIButton标题颜色 - 如何关闭它?

我创建了一个按钮.标题的颜色默认为黑色.但是当我按下它时,颜色会变成蓝色,再也不会变回来,这是怎么发生的?谁能告诉我为什么?我希望按钮的标题始终保持黑色.我怎样才能做到这一点?我试过了

[button setTitleColor:[UIColor darkTextColor] forState:UIControlStateHighlighted];
[button setTitleColor:[UIColor darkTextColor] forState:UIControlStateSelected];
Run Code Online (Sandbox Code Playgroud)

但是没有效果.当我在我的代码中添加它时,按钮的标题似乎总是蓝色.

代码如下.

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setFrame:CGRectMake(20, 360, 280, 44)];
[button setTitle:NSLocalizedString(@"Continue", @"Label: TextLabel in Continue button") forState:UIControlStateNormal];
button.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:20.0f];
button.titleLabel.textColor = [UIColor darkTextColor];
button.titleLabel.shadowColor = [UIColor blackColor];
button.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleBottomMargin|UIViewAutoresizingFlexibleWidth;

[self.view addSubview:button];
[button release];
Run Code Online (Sandbox Code Playgroud)

感谢大家.我解决了这个问题.我认为根本原因是

button.titleLabel.textColor = [UIColor darkTextColor];
Run Code Online (Sandbox Code Playgroud)

当我删除它,并使用

button setTitleColor:(UIColor) forState:(UIControlState);
Run Code Online (Sandbox Code Playgroud)

问题已经解决了!

title textcolor uibutton ios

40
推荐指数
4
解决办法
4万
查看次数

如何使用NSDateFormatter获取字符串"Yesterday"?

我想格式化我,NSDate以便昨天发生的日期将显示为"昨天".这可以使用NSDateFormatter吗?

nsdate nsdateformatter ios

9
推荐指数
1
解决办法
2328
查看次数

标签 统计

ios ×2

nsdate ×1

nsdateformatter ×1

textcolor ×1

title ×1

uibutton ×1