[英]Custom callout view for MKAnnotation?
The standard callout, a black bubble, is nice, but can this be customized? 标准标注,黑色泡泡,很好,但这可以定制吗? For instance I would like to make a white bubble version.
例如,我想制作一个白色泡泡版本。
There is a great answer to this problem here: Customizing the MKAnnotation Callout bubble 这里有一个很好的答案: 自定义MKAnnotation Callout气泡
Where this answer is given by @MathieuF: 答案由@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;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.