Reputation: 1
I need to turn the arrow on the map (customAnnotationView) so that the calloutView does not rotate (Example 1).
When I rotate only the image: The arrows are not set in the center and of different sizes (Example 2).
Example 1
Example 2
Example 1
annotationView?.transform = CGAffineTransform(rotationAngle: CGFloat((-180.0 * .pi / 180) - -customPointAnnotation.ang))
Example 2
annotationView?.image = UIImage(named: customPointAnnotation.pinCustomImageName)?.rotate(radians: CGFloat((90.0 * .pi / 180) - -customPointAnnotation.ang))
Upvotes: 0
Views: 239
Reputation: 1396
I hope it will Solve your problem
let pinImage = UIImage(named: "customPointAnnotation.pinCustomImageName")
let size = CGSize(width: 50, height: 50) // size of your choice
UIGraphicsBeginImageContext(size)
pinImage!.draw(in: CGRect(x: 0, y: 0, width: size.width, height: size.height))
let resizedImage = UIGraphicsGetImageFromCurrentImageContext()
let rotatedImage = . resizedImage rotate(radians: CGFloat((90.0 * .pi / 180) - -customPointAnnotation.ang)) //if still not set do check by changing image or by slightly changing redians angle values.
annotationView?.image = rotatedImage
Upvotes: 0