Disable backup storage on CAShapeLayer or CALayer subclass to prevent "dummy level" error warning

I want to overlay a large one CATiledLayer

on some vector art. For starters, I would like to use CAShapeLayer

which should be replaced with some custom subclass CALayer

or delegate.

It's good that it works. However, I get this warning on every redraw:

-[<CAShapeLayer: 0x1700daa0> display]: Ignoring bogus layer size (150000.000000, 150000.000000), contentsScale 1.000000, backing store size (150000.000000, 150000.000000)

How can I get rid of this warning correctly?

I suppose I don't need a fallback store as the whole point of this layer is that it (and continuously) draws the visible part of the layer.

One (accidentally discovered) way to prevent this error is to set it layer.contentsScale

to a small value or even zero, so that there is no "bogus size" in the backup store. (this property is commonly used to make @ 2x / @ 3x devices have high-res storage)

But this looks like a hack that will break my application one day. So how can I disable the backup storage for CALayer?

CATiledLayer (a subclass of CALayer) gives no such warning despite being the same size. I've looked into subclasses of CALayer or CAShapeLayer trying to replicate the CAShapeLayer, but this is pretty confusing. The CAShapeLayer doesn't seem to play by the same rules as me; my drawInContext:

renders the pixels of the vectors, while the layer draws its own vectors crisp, even within the same CALayer. The almost undocumented property layer.contents

only applies to the backup store for my pixel lines.

Is it still possible to create a CAShapeLayer with a public API?

+3


source to share





All Articles