From c2da75ca3422c3c20fcad1d2633ff715b29b8a8e Mon Sep 17 00:00:00 2001 From: Igor Khmurets Date: Sun, 16 Mar 2014 12:32:21 +0300 Subject: [PATCH] [ios] Added damping animation --- iphone/Maps/Categories/UIKitCategories.h | 2 ++ iphone/Maps/Categories/UIKitCategories.m | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/iphone/Maps/Categories/UIKitCategories.h b/iphone/Maps/Categories/UIKitCategories.h index 54e9f036c5..3ad673bf1f 100644 --- a/iphone/Maps/Categories/UIKitCategories.h +++ b/iphone/Maps/Categories/UIKitCategories.h @@ -40,6 +40,8 @@ @property (nonatomic) CGFloat height; @property (nonatomic) CGSize size; ++ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay damping:(double)dampingRatio initialVelocity:(double)springVelocity options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion; + @end diff --git a/iphone/Maps/Categories/UIKitCategories.m b/iphone/Maps/Categories/UIKitCategories.m index 1e72e0089b..cf975a4150 100644 --- a/iphone/Maps/Categories/UIKitCategories.m +++ b/iphone/Maps/Categories/UIKitCategories.m @@ -156,6 +156,14 @@ self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, size.width, size.height); } ++ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay damping:(double)dampingRatio initialVelocity:(double)springVelocity options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL))completion +{ + if ([UIView respondsToSelector:@selector(animateWithDuration:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion:)]) + [UIView animateWithDuration:duration delay:delay usingSpringWithDamping:dampingRatio initialSpringVelocity:springVelocity options:options animations:animations completion:completion]; + else + [UIView animateWithDuration:(duration * dampingRatio) delay:delay options:options animations:animations completion:completion]; +} + @end