为 MKAnnotationView 添加 Layer Mask,使其标题 window 从不显示

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

正如标题所说,我使用后:

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

显示标题(有问题的检查图像)的自定义视图在我按下地图中的注释视图时应该出现,但从未显示。

我看不出这些代码行如何影响此功能...

有人可以帮助我吗?

I don't see how those lines of code can affect this feature...

你不知道吗?好吧,面具的意思是“不要在我外面显示任何东西”(其中“我”是面具不透明的部分)。您在屏幕截图中显示的标题视图位于该遮罩之外,因此无法显示。它正在出现,好吧,它正试图出现(正如您可以通过查看 View Debugger 中的情况向自己证明的那样);但它不能,因为你把它屏蔽了。