【问题标题】:Cocoa Touch - Custom UILabelCocoa Touch - 自定义 UILabel
【发布时间】:2010-09-08 20:15:41
【问题描述】:

我正在尝试创建一个自定义 UILabel ,它将背景颜色设置为 clearColor(进一步添加了功能)。这样,我就不必为每个标签指定确切的属性,因为它们在标签的每个实例中都是固有的。

我在它们上尝试了几种变体,但都没有成功,我做错了什么?

@interface ABClearLabel : UILabel {
}
@end

@implementation ABClearLabel

- (id)init {
    if (self = [super init]) {
        self.backgroundColor = [UIColor clearColor];
    }
}

不幸的是,这不起作用(我已将 IB 中的标签类型设置为 ABClearLabel,实例变量和 @property 声明也是如此)。请帮忙。

【问题讨论】:

    标签: objective-c cocoa-touch uilabel


    【解决方案1】:

    玩过之后,IB 为我做了这件事——它创建了具有透明背景的标签。我不确定我将以前的标签设置为什么以使其不起作用。不需要自定义类。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多