【发布时间】: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.")
}
}
}
}
}
}
当它运行时,我收到消息“找到图像”。但唯一显示的是标记注释内的白色矩形。我错过了什么?
【问题讨论】:
-
你能显示你正在使用的图像类型以及它的框架吗?对于字形图像,我认为它必须是色调颜色的模板图像类型,并且我认为它有尺寸要求。文档:(developer.apple.com/documentation/mapkit/mkmarkerannotationview/…)
标签: ios swift mapkitannotation