我需要转动地图上的箭头(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))
答案 0 :(得分: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