views:

436

answers:

1

Hello there,

I'm trying to add a UILabel to an MKAnnotationView as a leftCalloutAccessoryView right after a pin got selected for the first time in the MKMapView. Adding the label is not a problem: The callout gets selected and opens, and this is when I add the label to the callout view. The callout gets automatically expanded to the left with a slide animation, and the new label including 2 lines is shown. Unfortunately I need to add the label after the Pin got selected because I need certain information about that Pin first.

The problem now is that the text in this label is somewhat "blurry", like it is not rendered correctly. When I deselect the callout and select it again, everything is drawn correctly.

This is the way I add the label:
During creation of the MKPinAnnotationView I register as an observer for the "selected" property of the view, since there is no delegate method for the selection of the pin. When the pin is selected in the view, my observer method fires and simply adds the text label to the view. (create UILabel with 2 lines, a clear background color and a bold white system font, set the leftCalloutAccessoryView, release the label). I tried setNeedsDisplay, setNeedsLayout and several other things, but no matter what, the text is still blurry in the label until the Pin is selected for the second time.

Any idea how I can get this Label to be drawn correctly without beeing blurry?

Thanks in advance!

+1  A: 

Are you sure your label is being located on a pixel boundary? I've seen blurryness when I've calculated a label frame programmatically and not taken into account that my calculations could return a non-integer value for the origin.

Jablair
I think so... I create the label using UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(5, 0, 30, 30)];I assume that the frame of the label is placed relative to the parent pin view. When the view is there and the callout opens, it draws correctly
Hutaffe
Worked for me. Thanks!
Matt S.