iphone - MKAnnotation 的自定义标注 View ?

标签 iphone objective-c ios mkannotation mkannotationview

标准的标注,一个黑色的气泡,很不错,但这可以定制吗?例如,我想制作一个白色气泡版本。

最佳答案

这里有一个很好的答案:Customizing the MKAnnotation Callout bubble

@MathieuF 给出的答案:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{   
MKAnnotationView *annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"loc"];

// Button
UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
button.frame = CGRectMake(0, 0, 23, 23);
annotationView.rightCalloutAccessoryView = button;

// Image and two labels
UIView *leftCAV = [[UIView alloc] initWithFrame:CGRectMake(0,0,23,23)];
[leftCAV addSubview : yourImageView];
[leftCAV addSubview : yourFirstLabel];
[leftCAV addSubview : yourSecondLabel];
annotationView.leftCalloutAccessoryView = leftCAV;

annotationView.canShowCallout = YES;

return pin;
}

关于iphone - MKAnnotation 的自定义标注 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6945045/

相关文章:

objective-c - 模糊 NSDictionary - 使用最近的键

ios - Restkit .20 请求超时间隔

iphone - 显示 HUD 的 OpenGL ES 在纹理 3D 对象顶部没有颜色

iphone - iPhone SDK中的ASIHTTP请求已取消错误

php - ASIHTTPRequest 将 json 发送到 php 服务器

objective-c - didSelectRowAtIndexPath 中的 EXC_BAD_ACCESS

ios - 用自己的initWithFrame初始化一个类可以吗?

objective-c - 需要知道哪些自定义 UIViews 在点击中

ios - 使用 Storyboard从 xib 或其他场景添加 subview

iphone - 在 SCEP 负载之后应该向设备发送什么响应?