2017-06-04 69 views
1

我想知道Mapbox是否有其他標註按鈕而不僅僅是提供的七個按鈕?Mapbox標註附件

let button = UIButton(type: .detailDisclosure) 

或者,如果有快速修復將這些UIButtons轉換爲UIImages以創建我自己的按鈕。

回答

1

是的,您可以使用方法func mapView(_ mapView: MGLMapView, leftCalloutAccessoryViewFor annotation: MGLAnnotation) -> UIView?func mapView(_ mapView: MGLMapView, rightCalloutAccessoryViewFor annotation: MGLAnnotation) -> UIView?來創建自己的。按鈕類型設置爲.custom

例如:

func mapView(_ mapView: MGLMapView, leftCalloutAccessoryViewFor annotation: MGLAnnotation) -> UIView? { 
    // We're not concerned with the user annotation. 
    guard annotation is CameraAnnotation || annotation is NoteAnnotation else { 
     return nil 
    } 
    // Callout height is fixed; width expands to fit its content. 
    let deleteButton = UIButton(type: .custom) 
    deleteButton.frame = CGRect(x: 0, y: 0, width: 50, height: 50) 
    deleteButton.setImage(UIImage(named: "delete"), for: .normal) 
    deleteButton.tag = 100 
    return deleteButton 
} 
+0

非常感謝您! – Cal

+0

沒問題。我可以要求你接受答案嗎?這不是一個自我的事情 - 它只是更多的代表解鎖更多的選擇,以幫助我的網站。 – Magnas

+0

當然,你已經幫助了我幾件事情! – Cal