MKMarkerAnnotationView字形图像不显示

时间:2018-07-23 21:11:41

标签: ios swift mapkitannotation

我正在尝试缩放大图像以适合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.")
                    }
                }
            }
        }
    }
}

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

1 个答案:

答案 0 :(得分:0)

您必须隐藏其余部分:

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