如何在点击MKPinAnnotationView时为注释添加动画?

时间:2014-08-20 08:52:05

标签: ios map annotations mapkit mkpinannotationview

我的地图视图中有一个自定义图钉,当我点击它时我需要放大图钉,当我按下其他图钉时返回默认尺寸,就像foursquare应用程序一样

这是我放大的代码,但是当我点击另一个引脚时,我如何将其恢复为默认值

- (void)mapView:(MKMapView *)mapView1 didSelectAnnotationView:(MKAnnotationView *)mapView2

{

id<MKAnnotation> annotation = mapView2.annotation;

if ([annotation isKindOfClass:[MKUserLocation class]]) {

    // this is where you can find the annotation type is whether it is userlocation or not...

    }

else

    {   

    float spanX = 0.00725;
    float spanY = 0.00725;
    MKCoordinateRegion region;

    region.center.latitude = annotation.coordinate.latitude;
    region.center.longitude = annotation.coordinate.longitude;
    region.span.latitudeDelta = spanX;
    region.span.longitudeDelta = spanY;
    [self.mapView setRegion:region animated:YES];

    CGRect frame;
    MapAnnotation* ann = annotation;
    NSInteger ind = [annotationArr indexOfObject:ann];
    frame.origin.x = self.cellScrollBar.frame.size.width * ind;
    frame.origin.y = 0;
    frame.size = self.cellScrollBar.frame.size;
    [self.cellScrollBar scrollRectToVisible:frame animated:YES]; // scroll to the cell of the tapped pin

    [UIView animateWithDuration:0.5 animations:^{
        mapView2.transform =CGAffineTransformMakeScale(1.3,1.3);
    }];
}
 }

请你帮我解决这个问题

0 个答案:

没有答案