3

Hi I have created a custom annotation in Sketch 3 and when I scale it down to fit into the map view it becomes blurry. How do I fix this?

Dauren Akilbekov
  • 4,627
  • 2
  • 27
  • 32
Trip Phillips
  • 430
  • 1
  • 5
  • 18

2 Answers2

3

I was having trouble with this too. Maybe this might help other people though, as you seem to have found a suitable solution.

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
}
patrickd
  • 275
  • 3
  • 14
2

You could try to set the filtering Mode of your Node texture to .Nearest

 let nodeTexture = SKTexture(imageNamed: "node")
 nodeTexture.filteringMode = .Nearest
 node = SKSpriteNode(texture: nodeTexture)
Devapploper
  • 6,062
  • 3
  • 20
  • 41
  • SKTexture and SKSpriteNode do not appear for me. Do I need to import any frameworks? – Trip Phillips Aug 12 '15 at 07:47
  • Completly forgot that, you need to work with spritekit – Devapploper Aug 12 '15 at 17:59
  • 1
    I wasn't able to get what I what from your code , but I decided to go on www.makeappicon.com and I was able to use the scaled down icon that it made for the Apple Watch and now the image quality is very good. Thanks for the help – Trip Phillips Aug 12 '15 at 19:07