I'm writing a multiplatform app that uses MapKit with custom tiles via MKTileOverlay
. The map should have buttons for zooming in and out. Those buttons set the region
of the MKMapView
with animation parameter.
I want to make this animation faster. While good for generic change of a region, it feels too slow when changing the region for the zooming purposes.
In general, I'm working with SwiftUI. But because MKTileOverlay
is not available there, the MKMapView
is being accessed via the UIViewRepresentable
and NSViewRepresentable
respectively.
On iOS, to make animation faster (reduce animation time), I'm using
UIView.animate(withDuration: 0.2) {
mapView.setRegion(region, animated: true)
}
and it achieves the goal.
On macOS, I tried:
NSAnimationContext.runAnimationGroup { context in
context.duration = 0.2
mapView.setRegion(region, animated: true)
}
and:
CATransaction.begin()
CATransaction.setAnimationDuration(0.2)
mapView.setRegion(region, animated: true)
CATransaction.commit()
but without success. The default animation duration is not overridden.
I appreciate any input you could give me.
Alexey