ios - Why isn't the center of my mapview's frame lining up its center coordinate? -
i'm trying render circle @ center of mapview. i'm displaying user's current location on mapview, , setting center of map there. these 2 not lining up, though.
here set circle:
[self.mapview setshowsuserlocation:yes]; cashapelayer *circle = [cashapelayer layer]; int radius = 50; circle.path = [uibezierpath bezierpathwithroundedrect:cgrectmake(0, 0, 2.0*radius, 2.0*radius) cornerradius:radius].cgpath; // set position of circle. // use frame of mapview subtracted circle radius determine center circle.position = cgpointmake(cgrectgetmidx(self.mapview.frame)-radius, cgrectgetmidy(self.mapview.frame)-radius); circle.fillcolor = [[uicolor alloc] initwithred:0.5 green:0.5 blue:0.6 alpha:0.3].cgcolor; circle.strokecolor = [uicolor blackcolor].cgcolor; circle.linewidth = 1; // add parent layer [self.mapview.layer addsublayer:circle]; // add 'crosshair' uiview *view = [[uiview alloc] init]; view.backgroundcolor = [uicolor blackcolor]; view.frame = cgrectmake(0, 0, 5, 5); [self.mapview addsubview:view]; view.center = self.mapview.center;
and in didupdateuserlocation delegate method have:
[self.mapview setcentercoordinate:userlocation.coordinate];
here's looks on simulator.
i want allow user pan , select region of map, i'm not sure if centercoordinate of map coinciding center of circle. help? thanks!
you may running same bug discovered recently. have reported apple , marked duplicate, perhaps it'll fixed in ios 7.1.
Comments
Post a Comment