0

我需要转动地图上的箭头(customAnnotationView),以便 calloutView 不会旋转(示例 1)。

当我仅旋转图像时:箭头未设置在中心并且大小不同(示例 2)。

示例 1 在此处输入图像描述

示例 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))
4

1 回答 1

0

我希望它能解决你的问题

 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
于 2019-08-01T11:54:05.677 回答