【发布时间】:2017-02-08 15:14:42
【问题描述】:
我尝试在func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) 上放大 MKAnnotation 的视图
正如您在动画中看到的那样,问题不仅在于 MKAnnotation 的 Pin 部分,而且 Callout 是否被缩放 - 有人知道如何解决这个问题吗?
我使用以下代码进行缩放动画(它是 UIView 的扩展)
func scaleUp(duration: TimeInterval = 0.2) {
self.transform = CGAffineTransform.identity
UIView.animate(withDuration: duration, delay: 0.0, options: [.curveLinear], animations: { () -> Void in
self.transform = CGAffineTransform(scaleX: 1.2, y: 1.2)
}) { (animationCompleted: Bool) -> Void in }
}
【问题讨论】:
-
不是通过变换来缩放视图,而是增加注释的图像的大小?
-
这是 UIView 的扩展 - 我已经更新了问题
-
@matt 感谢您的想法。似乎 MKAnnotationView 不使用 UIImageView 来显示图像,所以我无法访问 .transform
-
不,但它确实有一个
image。关于 UIImageView 我什么都没说,我特别建议反对使用变换。 -
还有一个想法:对于现有的注释,将另一个注释替换为您已用
transform缩放缩小 到与第一个相同大小的另一个注释,并将其up 放大到 100%。现在标注将是正常的。
标签: ios swift mapkit mkannotation mkannotationview