diff options
Diffstat (limited to 'platform/ios/Classes')
-rw-r--r-- | platform/ios/Classes/MuDocumentController.m | 14 | ||||
-rw-r--r-- | platform/ios/Classes/TapImage.h | 9 | ||||
-rw-r--r-- | platform/ios/Classes/TapImage.m | 37 |
3 files changed, 9 insertions, 51 deletions
diff --git a/platform/ios/Classes/MuDocumentController.m b/platform/ios/Classes/MuDocumentController.m index c9ac2e66..36f2c867 100644 --- a/platform/ios/Classes/MuDocumentController.m +++ b/platform/ios/Classes/MuDocumentController.m @@ -1,6 +1,5 @@ #include "common.h" -#import <TapImage.h> #import "MuPageViewNormal.h" #import "MuPageViewReflow.h" #import "MuDocumentController.h" @@ -165,10 +164,15 @@ static void saveDoc(char *current_path, fz_document *doc) } else { - UIView *iv = [[TapImage alloc] initWithResource:resource target:self action:selector]; - UIBarButtonItem *ib = [[UIBarButtonItem alloc] initWithCustomView:iv]; - [iv release]; - return ib; + UIView *buttonView; + BOOL iOS7Style = ([[UIDevice currentDevice].systemVersion floatValue] >= 7.0f); + UIButton *button = [UIButton buttonWithType:iOS7Style ? UIButtonTypeSystem : UIButtonTypeCustom]; + [button setImage:[UIImage imageNamed:resource] forState:UIControlStateNormal]; + [button addTarget:self action:selector forControlEvents:UIControlEventTouchUpInside]; + [button sizeToFit]; + buttonView = button; + + return [[UIBarButtonItem alloc] initWithCustomView:buttonView]; } } diff --git a/platform/ios/Classes/TapImage.h b/platform/ios/Classes/TapImage.h deleted file mode 100644 index af31ea5f..00000000 --- a/platform/ios/Classes/TapImage.h +++ /dev/null @@ -1,9 +0,0 @@ -#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 deleted file mode 100644 index 1a43813e..00000000 --- a/platform/ios/Classes/TapImage.m +++ /dev/null @@ -1,37 +0,0 @@ -#import "TapImage.h" - -static const NSTimeInterval TapDuration = 0.05; - -@implementation TapImage - -- (id)initWithResource:(NSString *)resource target:(id)targ action:(SEL)selector -{ - UIImage *image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:resource ofType:@"png"]]; - if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) - image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; - self = [super initWithImage:image]; - if (self) - { - 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 |