我有一个带有图像的UIImageView
,这个图像是典型的地图选择器。我在storyboard中将其放置在地图上并分配了一些约束。
当用户拖动我的地图时,那个图像保持不变,我想找到一种使它动画的方法 - 基本上我想把它压缩一点,以便看起来像是被拖动了。
我已经有两种方法:
func mapView(_ mapView: MKMapView, regionWillChangeAnimated animated: Bool) {
}
并且。
func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool) {
}
但是我不知道如何为UIImageView添加动画效果。
我尝试在regionWillChangeAnimated
中添加以下代码:
myPositionPicker.animate(withDuration: 1.5, delay: 0.05 * Double(index), usingSpringWithDamping: 0.8, initialSpringVelocity: 0, options: [], animations: {
yawpPositionPicker.transform = CGAffineTransform(translationX: 0, y: 0)
}, completion: nil)
(其中
myPositionPicker
是我的UIImageView
),但我遇到了错误。Static member animate cannot be used on instance of type UIImageView
我认为最适合我的动画是UIViewAnimationOptions.curveEaseIn
,但我不知道如何将其附加到我的UIImageView
上。你能给我一些提示吗?