自定义地图标注模糊。

3

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

2个回答

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
}

是的,我不得不使用makeappicon.com来缩小我的图像。那是我唯一能做到的方法。 - Trip Phillips

2
您可以尝试将节点纹理的过滤模式设置为.Nearest
 let nodeTexture = SKTexture(imageNamed: "node")
 nodeTexture.filteringMode = .Nearest
 node = SKSpriteNode(texture: nodeTexture)

SKTexture和SKSpriteNode在我的代码中没有出现。我需要导入任何框架吗? - Trip Phillips
完全忘记了,你需要使用 SpriteKit。 - Devapploper
1
我无法从你的代码中得到我想要的东西,但我决定去www.makeappicon.com,我能够使用它为Apple Watch制作的缩小图标,现在图像质量非常好。感谢你的帮助。 - Trip Phillips

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接