这里是一个工作的解决方案,通过捕捉MkMapViews当前的相机
以及在动画中设置MKMapViews摄影机。
MKMapCamera *mapCamera = [[self.mapView camera] copy]; // the fix 1 of 2
[UIView animateWithDuration:0.4 animations:^{
// top, left, bottom, right
self.mapView.layoutMargins = UIEdgeInsetsMake(y, 0, -y, 0);
[self.mapView setVisibleMapRect:[self.mapView visibleMapRect]
edgePadding:UIEdgeInsetsMake(self.offset, 0.0, 0.0, 0.0)
animated:YES];
[self.mapView setCamera:mapCamera]; // the fix 2 of 2
}];