1-我正在使用以下代码,但是我的自定义引脚不会像默认我的位置引脚那样显示气泡。2- 有没有办法自定义我的位置图钉以将颜色从默认的蓝色更改为红色,或者增加它的动画圆半径?
-(void) showMarkers
{
[self.mapView removeAnnotations:[self.mapView annotations]];
for (int i = 0 ; i < 1; i ++)
{
MKPointAnnotation *annotationPoint = [[MKPointAnnotation alloc] init];
Players *player = [self.playersArray objectAtIndex:i];
annotationPoint.coordinate = CLLocationCoordinate2DMake([player.latitude doubleValue], [player.longitude doubleValue]);
annotationPoint.title = player.name;
annotationPoint.subtitle = [NSString stringWithFormat:@"Level %@", player.level ];
[self.mapView addAnnotation:annotationPoint];
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(annotationPoint.coordinate, 1500, 1500);
MKCoordinateRegion adjustedRegion = [self.mapView regionThatFits:viewRegion];
[self.mapView setRegion:adjustedRegion animated:YES];
}
}
- (void)map:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
self.mapView.centerCoordinate = userLocation.location.coordinate;
myLocation = userLocation;
}
-(MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
if ([[annotation title] isEqualToString:@"Current Location"] )
{
return nil;
}
MKAnnotationView *annView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"players"];
annView.image = [UIImage imageNamed:@"marker.png"];
annView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
annView.canShowCallout = YES;
annView.enabled = YES;
[annView setUserInteractionEnabled:YES];
return annView;
}