3

是否可以制作一个带有标签和按钮等元素的自定义 UIView,并将其用作 CalloutView?

到目前为止,我通过文档阅读的内容并不意味着它是可能的。

可以更改左右按钮,以及为箭头添加自定义 UIImageView,但无法确定是否真的可以自定义整个视图。

4

1 回答 1

3

Yes - you just have to override the calloutViewForAnnotation callback. There is an example in the demo project (see inside AnnotationsViewController.m) where you can create a user defined UIView and return that

- (UIView*)mapView:(SKMapView *)mapView calloutViewForAnnotation:(SKAnnotation *)annotation
{
    //Custom callouts.
    if (annotation.identifier == self.annotation1.identifier)
    {
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0.0f, 0.0f, 200.0f, 50.0f)];
        view.backgroundColor = [UIColor purpleColor];
        view.alpha = 0.5f;
        return view;
    }

    return nil;// Default callout view will be used.
}
于 2015-08-03T06:38:34.457 回答