diff options
author | Paul Gardiner <paul.gardiner@artifex.com> | 2014-01-10 16:53:31 +0000 |
---|---|---|
committer | Paul Gardiner <paul.gardiner@artifex.com> | 2014-01-10 16:54:01 +0000 |
commit | 1453f662e9bfd4eaacd6edee4f09e60521d46d45 (patch) | |
tree | ffea358bc9073513bfba85646eaf0e814e355ef6 /platform/ios/Classes | |
parent | e7be17be8685c5b57bf51a778fd188dbd4c74039 (diff) | |
download | mupdf-1453f662e9bfd4eaacd6edee4f09e60521d46d45.tar.xz |
iOS: animate the custom buttons used for the iPhone build
Diffstat (limited to 'platform/ios/Classes')
-rw-r--r-- | platform/ios/Classes/TapImage.h | 4 | ||||
-rw-r--r-- | platform/ios/Classes/TapImage.m | 19 |
2 files changed, 22 insertions, 1 deletions
diff --git a/platform/ios/Classes/TapImage.h b/platform/ios/Classes/TapImage.h index 43234474..af31ea5f 100644 --- a/platform/ios/Classes/TapImage.h +++ b/platform/ios/Classes/TapImage.h @@ -1,5 +1,9 @@ #import <UIKit/UIKit.h> @interface TapImage : UIImageView +{ + id target; + SEL action; +} - (id)initWithResource:(NSString *)resource target:(id)obj action:(SEL)selector; @end diff --git a/platform/ios/Classes/TapImage.m b/platform/ios/Classes/TapImage.m index e02e8b7a..09c85189 100644 --- a/platform/ios/Classes/TapImage.m +++ b/platform/ios/Classes/TapImage.m @@ -1,5 +1,7 @@ #import "TapImage.h" +static const NSTimeInterval TapDuration = 0.05; + @implementation TapImage - (id)initWithResource:(NSString *)resource target:(id)targ action:(SEL)selector @@ -8,11 +10,26 @@ self = [super initWithImage:image]; if (self) { - UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:targ action:selector]; + target = targ; + action = selector; + UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTap)]; [self addGestureRecognizer:tap]; [tap release]; } return self; } +- (void) onTap +{ + [UIView animateWithDuration:TapDuration animations:^{ + self.backgroundColor = [UIColor darkGrayColor]; + } completion:^(BOOL finished) { + [UIView animateWithDuration:TapDuration animations:^{ + self.backgroundColor = [UIColor clearColor]; + } completion:^(BOOL finished) { + [target performSelector:action withObject:nil]; + }]; + }]; +} + @end |