我有一個UIImageView
在那裏有一個圖像,這個圖像是一個典型的地圖選擇器。我把它放在故事板的地圖上,並分配了一些限制條件。如何在用戶拖動MKMapView時爲UIImageView設置動畫效果?
當用戶拖動我的地圖時,該圖像保持不動,我想找到一種動畫的方式 - 基本上我想擠一點,所以它看起來像被拖動。
我已經有兩個方法:
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
。你能給我任何提示嗎?
有沒有辦法讓圖像稍稍傾斜?或拉伸/縮小圖像?我需要達到的效果不是通過上下移動圖像,而是拉伸,傾斜等。 – user3766930