自定义MKAnnotation标注气泡 [英] Customizing the MKAnnotation Callout bubble

查看:285
本文介绍了自定义MKAnnotation标注气泡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的申请地图页面有要求。我必须自定义Callout气泡。我需要添加一个图像,两个标签和一个具有特定高度和宽度的按钮。

I have a requirement in my application map page. I have to customize the Callout bubbles. I need to add an image, two labels and a button with specific height and width of each.

我已通过网络找不到合适的链接来解释如何自定义标注气泡。如果你们中的任何一个遇到或了解它,请与我分享。

I have gone through web and could not find a proper link that explains how to customize the callout bubbles. If any one of you come across or know about it please share with me.

任何简单的例子或链接都会非常棒。

any simple examples or links would be really great.

提前致谢
suresh

Thanks in advance 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;
}

有关更多信息,请查看: http://developer.apple .com / library / ios / #documentation/MapKit / Reference / MKAnnotationView_Class / Reference / Reference.html%23 // apple_ref / occ / cl / MKAnnotationView

For more informations, look at this : http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKAnnotationView_Class/Reference/Reference.html%23//apple_ref/occ/cl/MKAnnotationView

这篇关于自定义MKAnnotation标注气泡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆