CALayer - Shadow causes a performance hit?

后端 未结 5 1934
Happy的楠姐
Happy的楠姐 2020-12-13 02:33

So I am doing some custom animations on my navigationcontroller and the way it pushes and pops the viewControllers.

Everything runs smooth. As soon as I add the foll

5条回答
  •  眼角桃花
    2020-12-13 03:02

    Yes, shadow's are very expensive (especially a shadow that big -- play with the radius and you'll notice it makes a huge difference in the degree of slowdown you experience). One way to improve performance is to render it once to a CGImageContext and just display that image instead of having the layer re-render the shadow every time it redraws (but this doesn't work if the shadow needs to animate or something).

提交回复
热议问题