Interface Builder中的CATextLayer?

时间:2012-03-13 18:33:23

标签: ios xcode interface-builder nsattributedstring catextlayer

我想使用CATextLayerNSAttributedString的形式显示部分粗体文字 - 但仍然希望使用IB的便利进行定位。

有没有办法通过界面构建​​器放入CATextLayer?或者下一个最佳解决方案是什么?

1 个答案:

答案 0 :(得分:3)

您可以在IB中配置UIView子类,然后在代码中将layerClass设置为CATextLayer

+ (Class)layerClass;
{
    return [CATextLayer class];
}

在视图的init方法中配置您的CATextLayer属性。

要访问图层的属性:

CATextLayer *textLayer = (CATextLayer *)self.layer;
textLayer.string = @"Foo";
// etc...