Clip angles of MKPolyline

158 views Asked by At

I've currently got MKAnnoations with a circle image on them, displayed on an MKMapView. When I place down a MKPolyline the lines meet in the middle of the circle and then leave it. Is it possible to clip the ends of MKPolylines so that the lines just touch the edge of the circle, rather than going to the centre of the annoation?

Cheers, SebOH

enter image description here
P.S: I can't just put a white circle over it as the line is over a MKMapView that is unblockable

2

There are 2 answers

1
Stephen Furlani On BEST ANSWER

Using MKPathOverlayRenderer might be your best bet.

Using a CGPath, I believe you get a little bit more control over the shape than using MKAnnotations, and there are lots of references on how to subtract one path from another using CoreGraphics.

  1. Draw your lines into the overlay's CGContext.
  2. Mask the circles and/or erase the lines under the circles
  3. Draw your circles (or add them as MKAnnotations if you need them interactable?)

HTH

1
Adeel Ur Rehman On

The best possible way is to place a white circle with red border instead of transparent circle.