【发布时间】:2011-08-04 16:25:47
【问题描述】:
标准标注,黑色气泡,很好,但是可以自定义吗?比如我想做一个白色泡泡版。
【问题讨论】:
标签: iphone objective-c ios mkannotation mkannotationview
标准标注,黑色气泡,很好,但是可以自定义吗?比如我想做一个白色泡泡版。
【问题讨论】:
标签: 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;
}
【讨论】: