UIButton颜色问题 [英] UIButton color issues

查看:66
本文介绍了UIButton颜色问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改UIButton上文本的颜色。这是我目前的代码:

How can I change the color of the text on my UIButton. Here is my current code:

    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];

这是它的样子(忽略背景颜色和东西):

Here is what it looks like (ignore the background color and stuff):

现在,我怎样才能让箭头变红?如上所示,我已经有以下内容:

Now, how can I get the arrow to be red? As you see above, I already have the following:

[b1 setTitleColor:[UIColor redColor] forState:UIControlEventAllEvents];

但它不起作用。

推荐答案

尝试设置单个事件,例如:

Try setting the individual events, such as:

[b1 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];

这篇关于UIButton颜色问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆