【问题标题】:MKMarkerAnnotationView glyphimage doesn't displayMKMarkerAnnotationView 字形图像不显示
【发布时间】:2018-07-23 21:11:41
【问题描述】:

我正在尝试缩放大图像以适应 MKMarkerAnnotationView 子类的字形图像:

class MyAnnotationView: MKMarkerAnnotationView {
    var database = MyDatabase()

    override var annotation: MKAnnotation? {
        willSet {
            if let annotation = newValue as? MyAnnotation {
                canShowCallout = true
                markerTintColor = annotation.markerTintColor
                if let pic = annotation.pic {
                    if let image = database.picImage(pic: pic) {
                        print("Found image.")
                        self.contentMode = .scaleAspectFit
                        self.glyphImage = image
                    } else {
                        print("Didn't find image.")
                    }
                }
            }
        }
    }
}

当它运行时,我收到消息“找到图像”。但唯一显示的是标记注释内的白色矩形。我错过了什么?

【问题讨论】:

标签: ios swift mapkitannotation


【解决方案1】:

你必须隐藏其余的:

self.glyphText = ""
self.glyphTintColor = UIColor.clear
self.markerTintColor = UIColor.clear

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-05-25
    • 1970-01-01
    • 2013-12-14
    • 2021-03-17
    • 2018-06-14
    • 2014-11-14
    • 1970-01-01
    相关资源
    最近更新 更多