Hi, I'm making the map app to insert a custom MKOverlay. I specified the image in Asset catalog as an image of MKOVerlay. However, the overlay image in the map was reversed vertically as shown in the **** figure.
https://share.icloud.com/photos/0ofoyXKRlJnN_1phqRP79WBrw
I confirmed that the instance of UIImage to be rendered in a map had been created by specifying a correct asset name. The following is a part of the class inherits MKOverlayRenderer. I cannot understand the rotation of the image. Please teach me the reason for this phenomenon.
init(overlay: MKOVerlayWindIcon){
pOverlay = overlay
super.init(overlay: pOverlay)
if let tmpImg = GenerateImage(data: pOverlay.data){
pImageToRender = tmpImg
}else{
os_log(.error, "Failed to generage icon image")
}
}
override func draw(_ mapRect: MKMapRect, zoomScale: MKZoomScale, in context: CGContext) {
let rectToRender : CGRect = calcCGRect(for: zoomScale)
if let imageToReder = pImageToRender?.cgImage{
context.draw(imageToReder, in: rectToRender)
}else{
os_log("Invalid image was passed", log: OSLog.default, type: .debug)
}
}
func GenerateImage(data :WindData) -> UIImage?{
let assetName = "WI_337.5"
return UIImage.init(named: assetName)
}