0
上面是我想要做的事情的一个例子。我有两个图像,“marker.png”和“userImage.png”。我可以让每个单独显示为注释,但是我想将标记背景上的userImage覆盖为一个注释。看起来上面的图片用白色标记和顶部的图片做了这样的事情。我看到MKAnnotationView将UIImage作为一个属性,但没有UIImageView。我怎样才能完成我想要做的事情?
目前我能够只显示一个图像
func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {
if !(annotation is MKPointAnnotation) {
return nil
}
let reuseId = "CustomMarker"
var markerView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId)
if markerView == nil {
markerView = MKAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
markerView.image = UIImage(named: "marker.png")
}
else {
markerView!.annotation = annotation
}
return markerView
}
事实上,我很难理解你认为的难点在这里!在代码中绘制/组合图像与iOS编程一样基本。如果我误解了这个问题,请告诉我。 – matt 2014-12-05 00:58:13
我对开发相对比较陌生,所以这帮忙让我看看正确的东西。谢谢!懂得它的作用 – 2014-12-05 22:39:25
是的,我的书的第二章(就在“什么是视图”一章之后)是关于_drawing_的原因。这是真正了解如何在iOS编程中做的最基本和最重要的事情之一! – matt 2014-12-06 03:15:17