Mapbox标注附件

问题描述:

我想知道Mapbox是否有其他标注按钮而不仅仅是提供的七个按钮?Mapbox标注附件

let button = UIButton(type: .detailDisclosure) 

或者,如果有快速修复将这些UIButtons转换为UIImages以创建我自己的按钮。

是的,您可以使用方法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