我在我的应用程序地图页面上有一个要求,我必须自定义Callout气泡。我需要添加一个图片、两个标签和一个按钮,每个元素都有特定的高度和宽度。
我已经查看了网络,没有找到一个合适的链接来解释如何自定义Callout气泡。如果你们中的任何人遇到或知道,请与我分享。
任何简单的示例或链接都会非常好。
提前感谢 suresh
我在我的应用程序地图页面上有一个要求,我必须自定义Callout气泡。我需要添加一个图片、两个标签和一个按钮,每个元素都有特定的高度和宽度。
我已经查看了网络,没有找到一个合适的链接来解释如何自定义Callout气泡。如果你们中的任何人遇到或知道,请与我分享。
任何简单的示例或链接都会非常好。
提前感谢 suresh
一个帮助你的例子:
- (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 annotationView;
}