0

Does anyone know of any code to draw the pins we see in MKPinAnnotationView in a regular UIView?

The motivation is to remove the hundreds of different colored pin images we are currently bundling with our app to drop all over medical images (regular UIView backed - not MKMapView). All I really need is to alter the pin color programmatically .

NB: I am not talking about the callout as seen in SMCalloutView etc .

This is to be used outside MKMapView. They are dropped into a normal UIView.

Nathaniel Waisbrot
  • 23,261
  • 7
  • 71
  • 99
Paul de Lange
  • 10,613
  • 10
  • 41
  • 56

1 Answers1

0

Here are two approaches to consider:

  1. Ship a single pin image - say, red. Use the Core Image CIHueAdjust filter to change it to other colors.

  2. Ship a pin image with a white bulb, and an alpha-channel-only mask image that selects the pixels in the bulb. Use Core Graphics to create new pin images dynamically at runtime. You'll want to draw the white bulb pin into a bitmap context. Then use the mask image to set the context's clipping mask. Finally, fill the context with whatever color you want the bulb to be.

rob mayoff
  • 375,296
  • 67
  • 796
  • 848