UIImage as CAShapeLayer contents

core-animation, ios, objective-c

Solution

CAShapeLayer doesn't work that way. You would create a normal CALayer with the image as its content and then use the shape layer as the mask of that layer to achieve the effect you are after.

Problem

If I create a CAShapeLayer with just a background color it shows up, but if i set the content to an image, nothing shows. ``` CAShapeLayer* leftDot = [CAShapeLayer layer]; leftDot.opacity = 1.0; leftDot.frame = CGRectMake(leftRef.CGPointValue.x, leftRef.CGPointValue.y, 2 * radius, 2 * radius); leftDot.position = CGPointMake(leftRef.CGPointValue.x + 4, leftRef.CGPointValue.y + 4); leftDot.cornerRadius = radius; [leftDot setContents:[UIImage imageNamed: @"glow.png"]]; [self.layer addSublayer: leftDot]; ```

Original source