gpt4 book ai didi

ios - 如何隐藏 map (或使其统一颜色),同时将图钉保持在顶部?

转载 作者:行者123 更新时间:2023-11-30 13:51:03 25 4
gpt4 key购买 nike

我有一张来自mapKit的传统 map ,在各自的位置有一组图钉。我试图将图钉保持在同一位置,同时使 map 不可见。有什么办法可以做到这一点吗?谢谢,

最佳答案

好吧,我不得不承认这让我很好奇!我不知道有什么干净的方法可以做你想做的事情,尽管我怀疑你可以围绕添加叠加层做一些有趣的技巧。

您可能想要尝试的一种解决方案是使用 viewForAnnotation() 提取 map 上每个图钉注释的位置,将其转​​换为您的 View ,然后在其位置添加自定义 View 。然后,您可以隐藏整个 map (这将隐藏其图钉),将假图钉留在原处。

在我的脑海中,它看起来像这样:

let annotations = mapView.annotations

for annotation in annotations {
if let annotationView = mapView.viewForAnnotation(annotation) {
let transformedFrame = view.convertRect(annotationView.frame, fromView: annotationView.superview)

let testView = UIView(frame: transformedFrame)
testView.backgroundColor = UIColor.redColor()

view.addSubview(testView)
}
}

但是,本地图 View 移动时,您会遇到问题,因此您可能需要跟踪假图钉并适本地移动它们。

关于ios - 如何隐藏 map (或使其统一颜色),同时将图钉保持在顶部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34256387/

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