folk-lore
folk-lore

Reputation: 1

How to turn the arrow(image) so that it does not turn CalloutView

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 enter image description here

Example 2 enter image description here

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

Answers (1)

Abu Ul Hassan
Abu Ul Hassan

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

Related Questions