简体   繁体   English

向 MKAnnotationView 添加图层蒙版,使其标题窗口永不显示

[英]Adding Layer Mask to MKAnnotationView, makes its title window never show

As the title says after I use :正如我使用后标题所说:

func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {

...

let shapeLayer = CAShapeLayer()
shapeLayer.path = UIBezierPath(ovalIn: rect).cgPath
shapeLayer.backgroundColor = backgroundColor?.cgColor

mkAnnotationView?.layer.mask = shapeLayer //<- window showing title stops working

显示标题的窗口

The custom view showing the title (check image in question) that should appear when I press the annotation view in the map, never shows.当我按下地图中的注释视图时,显示标题(检查有问题的图像)的自定义视图从不显示。

I don't see how those lines of code can affect this feature...我看不出这些代码行会如何影响此功能...

Can someone help me?有人能帮我吗?

I don't see how those lines of code can affect this feature...我看不出这些代码行会如何影响此功能...

You don't?你没有? Well, a mask means "don't show anything outside me" (where "me" is the parts of the mask that are opaque).好吧,面具的意思是“不要在我之外展示任何东西”(其中“我”是面具的不透明部分)。 The title view you're showing in your screen shot is outside that mask, so it cannot show.您在屏幕截图中显示的标题视图在该蒙版之外,因此无法显示。 It's coming into existence, all right, and it's trying to appear (as you can prove to yourself by looking at the situation in the View Debugger);它正在出现,好吧,它正在尝试出现(正如您可以通过查看 View Debugger 中的情况向自己证明的那样); but it can't, because you masked it out.但它不能,因为你掩盖了它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM