gpt4 book ai didi

ios - 是否可以为 SKCalloutView 使用自定义 View ?

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:58:10 25 4
gpt4 key购买 nike

是否可以使用 Label 和 Button 等元素制作自定义 UIView,并将其用作 CalloutView?

到目前为止,我通过文档阅读的内容并未暗示这是可能的。

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

最佳答案

是的——您只需覆盖 calloutViewForAnnotation 回调。演示项目中有一个示例(参见 AnnotationsViewController.m 内部),您可以在其中创建用户定义的 UIView 并返回它

- (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.
}

关于ios - 是否可以为 SKCalloutView 使用自定义 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31757164/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com