【发布时间】:2011-06-22 00:45:57
【问题描述】:
如何更改 UIButton 上文本的颜色。这是我当前的代码:
UIButton *b1 = [[UIButton alloc] init];
b1.frame = CGRectMake(280,395,30,30);
[[b1 layer] setCornerRadius:8.0f];
[[b1 layer] setMasksToBounds:YES];
[[b1 layer] setBorderWidth:1.0f];
[[b1 layer] setBackgroundColor:[botCol CGColor]];
b1.titleLabel.font = [UIFont boldSystemFontOfSize:24];
[b1 setTitleColor:[UIColor redColor] forState:UIControlEventAllEvents];
[b1 addTarget:self action:@selector(NextButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
[b1 setTitle:@">" forState:UIControlStateNormal];
[self.view addSubview:b1];
这是它的样子(忽略背景颜色和其他东西):
现在,我怎样才能让箭头变成红色?正如你在上面看到的,我已经有了以下内容:
[b1 setTitleColor:[UIColor redColor] forState:UIControlEventAllEvents];
但它不起作用。
【问题讨论】: