iOS mapView animatesDrop

标签 ios xcode animation annotations mkmapview

在我的 map View 中,我目前将注释的 bool animatesDrop 设置为 NO。这是因为当 mapView 注释在 viewWillAppear 期间绘制时,我不会在它们动画时显示。但是,我还有一个刷新按钮用于重新绘制注释,并希望它们在按下时动画化(放下)。有没有办法做到这一点?谢谢。

-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {

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

        return nil;
    }

    MyPin = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"current"];

    UIButton *calloutButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];

    UIButton *directionsButton = [UIButton buttonWithType:UIButtonTypeCustom];
    directionsButton.frame = CGRectMake(0, 0, 23, 23);
    [directionsButton setBackgroundImage:[UIImage imageNamed:@"directions.png"] forState:UIControlStateNormal];

    MyPin.leftCalloutAccessoryView = directionsButton;
    MyPin.rightCalloutAccessoryView = calloutButton;
    MyPin.draggable = NO;
    MyPin.highlighted = NO;
    MyPin.animatesDrop= YES;
    MyPin.canShowCallout = YES;

    return MyPin;
}

最佳答案

“硬球”方法是建立一个 bool 属性,该属性在 viewWillAppear 中设置为 false,但在按钮的操作中设置为 true。将 MyPin.animatesDrop 设置为 viewForAnnotation 中的属性。不知道有什么“优雅”的解决方案。

关于iOS mapView animatesDrop,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15890854/

相关文章:

ios - 支持 iOS 10 的 Xcode 7.3.1

animation - 在哪里下载很酷的动画进行测试?

ios - (Swift)状态栏外观UIImagePickerController

iphone - 我需要一个非常简单的 MKCircle 覆盖实现

ios - 注销/清除数据的 Objective-C 约定是什么?

ios - 如何使用 SWIFT 处理 MPMoviePlayerController 中的控件?

ios - Swift:AVAudioPlayer 不播放,线程可能出现错误?

xcode - 如何组织以前由GCC Make编译的C源文件并将其构建为Xcode包?我有重复的符号_main错误

ios - 移动时淡入淡出 UIView

iphone - 为 UIFont 大小的变化设置动画