Cod*_*Guy 3 iphone uibutton ios
如何更改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];
Run Code Online (Sandbox Code Playgroud)
这是它的样子(忽略背景颜色和东西):
现在,我怎么能让箭头变成红色?如您所见,我已经有以下内容:
[b1 setTitleColor:[UIColor redColor] forState:UIControlEventAllEvents];
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
尝试设置各个事件,例如:
[b1 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
10019 次 |
最近记录: |