简体   繁体   中英

Mapkit annotation image resolution

I've changed the annotation pin to a custome image, and it works great. However the image looks a little rough around the edges when it drops in the mapview. Does anyone know how to sharpen the image up?

Thanks.

I had the same problem and solved it by using UIGraphicsImageRenderer to create the images. Now they are sharp.

let whiteImage = UIImage(named: "white")

let size = CGSize(width: 60, height: 60)

  let myImage = UIGraphicsImageRenderer(size: size).image { imageContext in
      let context = imageContext.cgContext
      whiteImage?.draw(in: CGRect(origin: .zero, size: CGSize(width: 70, height: 90)))
  }

annotationView!.image = myImage

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM