On a CAShapeLayer, I’ve drawn a closed UIBezierPath. I can fill this shape by setting the fillColor, however I want to fill the shape with a gradient. How can I set up the CAGradientLayerso it clips to the shape outlined by the bezier path?
On a CAShapeLayer , I’ve drawn a closed UIBezierPath . I can fill this
Share
What you want is a mask. CAGradientlayer has a -setMask method that can clip it to the bounds of your shape like so:
[gradientLayer setMask:shapeLayer];