Topics

CATiledLayer in NSView (Mac) -- how?


Graham Cox
 

Does anyone have sample code or just a few hints how to use CATiledLayer in a NSView on Mac?

I’m reasonably au fait with using layers in a view in general, but this one is very minimally documented and doesn’t seem to work in quite the expected way. I’d like my app to work similarly to how Maps works, which I believe uses this class internally.

—Graham


Graham Cox
 

OK, I have this problem generally solved.

There’s one more thing I’d like to ask though - when a tile draws to the screen, it is animated. In some cases that’s annoying, like when something you’re drawing changes state, and lies across tile boundaries - one tile can animate before the other producing a momentary visible edge.

I’d like to turn off animation altogether for this, but I can’t see how to do it. Normally, putting a state change inside a [CATransaction begin] and [CATransaction commit] and setting the current transaction’s animation time to 0 works, but since this one is handled automatically, I don’t get a chance to do that.

Any ideas how to suppress animation for CATiledLayer when it draws to the screen?

—Graham

On 24 Jul 2020, at 12:35 pm, Graham Cox <graham@mapdiva.com> wrote:

Does anyone have sample code or just a few hints how to use CATiledLayer in a NSView on Mac?

I’m reasonably au fait with using layers in a view in general, but this one is very minimally documented and doesn’t seem to work in quite the expected way. I’d like my app to work similarly to how Maps works, which I believe uses this class internally.

—Graham