自定义标记图标的iOS质量差
答
你好你添加资产给你项目还是只有一个图像?
因此,您需要将图像资源(bigMarker.png,[email protected],[email protected])添加到项目资产中,如截图。这工作正常在iOS 9
,而我的代码示例中的viewDidLoad
// Add custom position in Kansas
CustomAnnotation *annotation = [CustomAnnotation new];
annotation.title = @"Elevation Burger";
annotation.subtitle = @"The best buns...";
annotation.coordinate = CLLocationCoordinate2DMake(39.0119020f,-98.4842460f);
[self.myMap addAnnotation:annotation];
而这其中的代表
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
MKAnnotationView *annotationView = nil;
if (annotation != mapView.userLocation) {
annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:nil];
annotationView.canShowCallout = YES;
annotationView.image = [UIImage imageNamed:@"bigMarker"];
annotationView.leftCalloutAccessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"burgerBitmap"]];
UIButton *accessoryButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
UIImage *disclosureButtonImage = [[UIImage imageNamed:@"disclosure"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
[accessoryButton setImage:disclosureButtonImage forState:UIControlStateNormal];
annotationView.rightCalloutAccessoryView = accessoryButton;
}
return annotationView;
}
没有,只是一个形象 – niskatqq
@niskatqq我刚刚编辑了我的评论,所以请尝试 –
现在感谢我了解 – niskatqq