嗨,我正在使用 iPhone 中的地图。我正在旋转带有方向的地图视图。地图正在旋转,但移动不顺畅。
我正在使用下面的代码来旋转地图。谁能告诉我有关顺利旋转地图视图的任何建议?
float oldRad = -manager.heading.trueHeading * M_PI / 180.0f;
float newRad = -newHeading.trueHeading * M_PI / 180.0f;
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.rotation"];
theAnimation.fromValue = [NSNumber numberWithFloat:oldRad];
theAnimation.toValue=[NSNumber numberWithFloat:newRad];
theAnimation.duration = 0.5f;
[mapView setTransform:CGAffineTransformMakeRotation(newRad)];
CGPoint anchorPoint = CGPointMake(0, 0);
[[mapView annotations] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop)
{
MKAnnotationView * view = [mapView viewForAnnotation:obj];
[view setTransform:CGAffineTransformMakeRotation(newRad)];
[view setCenterOffset:CGPointApplyAffineTransform(anchorPoint, CGAffineTransformMakeRotation(newRad))];
}];