UIView self.layer.shouldRasterize = YES and performance issues

前端 未结 2 1407
执笔经年
执笔经年 2020-12-05 05:23

I would like to share my experience from using self.layer.shouldRasterize = YES; flag on UIViews.

I have a UIView class hierarchy that has

2条回答
  •  庸人自扰
    2020-12-05 06:06

    Turning OFF self.layer.shouldRasterize increases performance to normal levels.

    Why is that?

    According to a video on apple's developers site (I cannot remember the video, help please?) the rule for self.layer.shouldRasterize is that simple: If all of your subviews are static (their position, contents etc, are not changing or animating) then it is beneficiary to turn self.layer.shouldRasterize ON. On the other side if any of the subviews are changing then the framework needs to re-cache the view hierarchy and this is a huge bottleneck. Under the hood the bottleneck is the memory copying between CPU and GPU.

提交回复
热议问题