ios - Mapbox 标注配件

标签 ios swift annotations mapbox callout

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

let button = UIButton(type: .detailDisclosure)

或者如果有一个快速修复方法可以将这些 UIButton 转换为 UIImage 以创建我自己的按钮。

最佳答案

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

关于ios - Mapbox 标注配件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44359240/

相关文章:

javascript - 网站导航在 WKWebview 中不起作用

ios - WKWebView 加载完成后,事件指示器不会停止旋转

annotations - Kotlin 注释 IntDef

java - 在 BeanPostProcessor 实现中获取 bean 的注解

ios - 从 UIPageViewController 点指示器中删除黑条

android - React Native - 设置 TextInput 光标位置

ios - 转换实现协议(protocol)的 View Controller

ios - Xcode 8 - 当用户点击背景时让键盘消失

java - Wildfly 忽略 Jackson 注释并且不使用 @Provider 类

ios - 导航栏不透明