123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- #import "CCHFadeInOutMapAnimator.h"
- #import "CCHMapClusterController.h"
- #import <MapKit/MapKit.h>
- @implementation CCHFadeInOutMapAnimator
- - (instancetype)init
- {
- self = [super init];
- if (self) {
- _duration = 0.2;
- }
- return self;
- }
- - (void)mapClusterController:(CCHMapClusterController *)mapClusterController didAddAnnotationViews:(NSArray *)annotationViews
- {
-
- #if TARGET_OS_IPHONE
- for (MKAnnotationView *annotationView in annotationViews)
- {
- annotationView.alpha = 0.0;
- }
-
- [UIView animateWithDuration:self.duration animations:^{
- for (MKAnnotationView *annotationView in annotationViews) {
- annotationView.alpha = 1.0;
- }
- }];
- #endif
- }
- - (void)mapClusterController:(CCHMapClusterController *)mapClusterController willRemoveAnnotations:(NSArray *)annotations withCompletionHandler:(void (^)(void))completionHandler
- {
- #if TARGET_OS_IPHONE
- MKMapView *mapView = mapClusterController.mapView;
- [UIView animateWithDuration:self.duration animations:^{
- for (id<MKAnnotation> annotation in annotations) {
- MKAnnotationView *annotationView = [mapView viewForAnnotation:annotation];
- annotationView.alpha = 0.0;
- }
- } completion:^(BOOL finished) {
- if (completionHandler) {
- completionHandler();
- }
- }];
- #else
- if (completionHandler) {
- completionHandler();
- }
- #endif
- }
- @end
|