Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to set z-order in the annotation view layer?

I want to have some annotationView images appear on top of the others so they are easier to see. Is there a way to set the order?

I thought I would try something like

[theMap addAnnotations:arrayOfLessImportantItems];
[theMap addAnnotations:arrayOfMoreImportantItems];

But it is obvious after trying this that the delegate method MKMapViewDelegate mapView:viewForAnnotation doesn't observe any particular order when it puts them down. (Since the annotation views come from a pool, the delegate must be adding and removing annotationView images as the map is shifted around on the screen.)

But I do have a small number items that I want to be easier to see, and they are getting buried behind the less important map pins. Is there a way to overcome this?

like image 623
Jim Avatar asked Oct 28 '11 06:10

Jim


1 Answers

You could also use the zPosition property from CALayer (you will have to include QuatzCore.h) to change the z-index of the view.

yourView.layer.zPosition = 1;

Works just the way it would with html/css :)

like image 188
smihael Avatar answered Nov 15 '22 04:11

smihael