How to draw markers on a zoomable UIView using UIScrollView and CATiledLayer

405 views Asked by At

I want to draw markers on a zoomable UIView that's using UIScrollView and CATiledLayer. I'm currently using the same setup as the PhotoScroller demo app from Apple. I've no problem drawing shapes, but i want them to stay on the same location even after zooming. Can i use a transformation matrix for that? Or do i have to redraw the shapes after or during zooming? That seems like a costly operation.

I don't want to scale the shapes i'm drawing. So using an scaling transformation isn't possible.

I'm curious how the MapView implements this functionality. Anyone any idea?

1

There are 1 answers

1
bshirley On BEST ANSWER

If you want the "marker" to not scale with the zooming, i'm assuming it's some kind of tool display.

I'd suggest not placing it in the content view of the scroll view - either directly subview of the scroll view or a sibling of the scroll view and displayed above it.

Another option is to act on the scroll delegate and zoom delegate methods to resize/replace the marker so it looks like it's not moving. Possibly more work, but there may be benefits.