gpt4 book ai didi

swift - 如何转动箭头(图像),使其不转动 CalloutView

转载 作者:行者123 更新时间:2023-11-30 10:38:46 24 4
gpt4 key购买 nike

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

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

示例1 enter image description here

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

最佳答案

希望能解决您的问题

 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

关于swift - 如何转动箭头(图像),使其不转动 CalloutView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57307676/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com