开发者

Is there a simple way to let a layer throw an smooth shadow?

开发者 https://www.devze.com 2023-01-01 04:59 出处:网络
I was drawing a path into a layer. Lets say I can\'t access that drawing code in any way, because it comes from a compiled lib. Now I want to let that layer throw a shadow which matches the shape of i

I was drawing a path into a layer. Lets say I can't access that drawing code in any way, because it comes from a compiled lib. Now I want to let that layer throw a shadow which matches the shape of its irregular content shape.

Is there an easy way to do it? Or must I draw like 20 of those layers and scale them up on every iteration, adjusting their a开发者_运维技巧lpha and letting the GPU do the extraordinarily heavy compositing?


every CALayer has the following properties:

  • shadowOpacity
  • shadowRadius
  • shadowOffset
  • shadowColor
  • shadowPath

If you set shadowOpacity to something other than 0 (the default) you'll see a shadow.
(CALayer docs)

0

精彩评论

暂无评论...
验证码 换一张
取 消