Since an MGLAnnotationView is a UIView you can use familiar APIs to manipulate it. For example, on devices that support 3D touch, you can transform the view as a function of the touch force.
override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesMoved(touches, withEvent: event)
if let touch = touches.first {
let normalizedForce = touch.force / touch.maximumPossibleForce * 2.5
self.transform = CGAffineTransformMakeScale(1 + normalizedForce, 1 + normalizedForce)
}
}
override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) {
super.touchesCancelled(touches, withEvent: event)
UIView.animateWithDuration(0.25) {
self.transform = CGAffineTransformMakeScale(1, 1)
}
}
override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesEnded(touches, withEvent: event)
UIView.animateWithDuration(0.25) {
self.transform = CGAffineTransformMakeScale(1, 1)
}
}