Question

I would like to use a CATextLayer to display some partially bolded text in the form of a NSAttributedString - but would still like to use the convenience of IB for positioning.

Is there a way to drop in a CATextLayer with interface builder? Or what is the next best solution?

Was it helpful?

Solution

You could configure a UIView subclass in IB then set its layerClass to CATextLayer in code:

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

In the view's init method(s) configure your CATextLayer properties.

To access the layer's properties:

CATextLayer *textLayer = (CATextLayer *)self.layer;
textLayer.string = @"Foo";
// etc...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top