繁体   English   中英

MKMarkerAnnotationView字形图像不显示

[英]MKMarkerAnnotationView glyphimage doesn't display

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

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

您必须隐藏其余部分:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM