diff options
author | Matt Holgate <matt@emobix.co.uk> | 2014-07-07 12:30:25 +0100 |
---|---|---|
committer | Matt Holgate <matt@emobix.co.uk> | 2014-07-07 12:30:25 +0100 |
commit | 184c4f75f9697877c7a8f1d512bef23f557b0c04 (patch) | |
tree | f4906f0e1397fbeced24240d4efb755f54ab00e4 /platform/ios/Classes | |
parent | 0144342e08e2bbd0be9a7ae562a7053be12dcb1e (diff) | |
download | mupdf-184c4f75f9697877c7a8f1d512bef23f557b0c04.tar.xz |
Fix disabled state of bar buttons on iPhone/iPod Touch.
Previously on iOS 7, bar buttons didn't change visually when disabled.
Also improves the look and feel - the buttons are now tinted in the
highlighted state rather than showing a grey background. On iOS 7, the
iPhone/iPad buttons style match.
Tested on iOS 6 iPad/iPod and iOS 7 iPad/iPod.
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 |