【问题标题】:Problem with .shadowColor with CustomUIButtonCustomUIButton 的 .shadowColor 问题
【发布时间】:2011-09-16 15:51:18
【问题描述】:

我将 UIButton 子类化为我的 UIButton 制作自定义渐变背景。 UIButtons 已正确连接,并且可以完美运行。

但是,当我尝试添加红色阴影时,它会被添加,但它始终是灰色的。它忽略了我的 .shadowColor 声明。这里是相关代码。

@implementation CustomUIButton
...
    -(void)awakeFromNib
    {
    ...
    [self titleLabel].shadowColor = [UIColor redColor];
    [self titleLabel].shadowOffset = CGSizeMake(1.0, 1.0);
    ...
    }
...

有什么想法吗? 谢谢

【问题讨论】:

    标签: iphone ios xcode uibutton


    【解决方案1】:

    UIButton 实例需要知道要为哪个控件状态设置颜色。试试下面的方法。

    [self setTitleShadowColor:[UIColor redColor] forState:UIControlStateNormal];
    

    【讨论】:

      猜你喜欢
      • 2012-01-25
      • 1970-01-01
      • 2022-10-09
      • 2022-01-16
      • 2018-02-01
      • 2017-07-19
      • 1970-01-01
      • 2020-02-29
      相关资源
      最近更新 更多