自定义地图注释模糊

时间:2015-08-11 21:32:22

标签: swift mapkitannotation sketch-3

您好我在Sketch 3中创建了一个自定义注释,当我缩小它以适应地图视图时,它变得模糊。我该如何解决这个问题?

2 个答案:

答案 0 :(得分:3)

我也遇到了麻烦。也许这可能对其他人有所帮助,因为你似乎找到了合适的解决方案。

func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
    let reuseId = "id"
    var anView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId)
    if anView == nil {
        anView = MKAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
        anView!.canShowCallout = true
    }
    else {
        anView!.annotation = annotation
    }

    anView!.image = yourFullSizeImage
    anView!.frame.size = CGSize(width: 50, height: 50) //Resize frame AFTER setting image, for me resizing frame first did not work

    return anView
}

答案 1 :(得分:2)

您可以尝试将节点纹理的过滤模式设置为.Nearest

 let nodeTexture = SKTexture(imageNamed: "node")
 nodeTexture.filteringMode = .Nearest
 node = SKSpriteNode(texture: nodeTexture)