2017-05-26 74 views
0

我正在使用適用於iOS的Google Maps SDK創建自定義標記信息窗口。默認(第一張圖片)在標記上方呈現錨點。iOS:Google Maps API - 自定義MarkerInfoWindow Anchor

我創建了一個自定義視圖與150x150 pts一個自由xib並加載它到委託:

func mapView(_ mapView: GMSMapView, markerInfoWindow marker: GMSMarker) -> UIView?

我怎麼會作出這樣的作爲默認的相同的效果呈現,如果可能,創造條件,這陰影效果標籤呢?

這是內置於SDK中嗎?

enter image description here [enter image description here]

回答

0

您可以設置infoWinwod錨這樣的:marker.infoWindowAnchor = CGPoint(x: 0.5, y: 0.4),你可以做到這裏面

func mapView(_ mapView: GMSMapView, markerInfoWindow marker: GMSMarker) -> UIView? { 
     let infoWindow = Bundle.main.loadNibNamed("CustomInfoWindow", owner: self.view, options: nil)!.first! as! CustomInfoView 
     marker.infoWindowAnchor = CGPoint(x: 0.5, y: 0.4) 
     return infoWindow 
    } 

理論上,如果你想擁有信息窗口下的三角形,你可以創建圖像並將其放入自定義infoWindow中,並將視圖背景設置爲清晰的顏色。

爲了給予影子,你可以使用相同的技術,就像你將它添加到任何其他UIView

相關問題