From 7bd2c7a5fedb7b39de0396a7a93f8cad7d5d5036 Mon Sep 17 00:00:00 2001 From: Paul Pilone Date: Thu, 16 Jul 2015 00:15:06 -0400 Subject: [PATCH] Adds user interaction option to shake animation. --- UIView+Shake.h | 3 ++- UIView+Shake.m | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/UIView+Shake.h b/UIView+Shake.h index 84f3dc4..647b409 100644 --- a/UIView+Shake.h +++ b/UIView+Shake.h @@ -26,7 +26,8 @@ typedef enum : NSUInteger { SCShakeOptionsAtEndRestart = 256, SCShakeOptionsAtEndComplete = 512, SCShakeOptionsAtEndContinue = 1024, - SCShakeOptionsAutoreverse = 2048 + SCShakeOptionsAutoreverse = 2048, + SCShakeOptionAllowsUserInteraction = 4096 } SCShakeOptions; diff --git a/UIView+Shake.m b/UIView+Shake.m index afa7568..80c103d 100644 --- a/UIView+Shake.m +++ b/UIView+Shake.m @@ -115,7 +115,8 @@ - (void)_doAnimation:(CGFloat)direction { CGFloat force = shakeInfo.force * interpolationRatio * direction; CGFloat iterationDuration = shakeInfo.iterationDuration; - [UIView animateWithDuration:iterationDuration animations:^{ + UIViewAnimationOptions animationOptions = HAS_OPT(options, SCShakeOptionAllowsUserInteraction) ? UIViewAnimationOptionAllowUserInteraction : 0; + [UIView animateWithDuration:iterationDuration delay:0 options:animationOptions animations:^{ [self _animate:force shakeInfo:shakeInfo]; } completion:^(BOOL finished) { if (shakeInfo.shaking) {