diff --git a/Classes/BITStoreButton.h b/Classes/BITStoreButton.h index 0e5d09765c..482534ef11 100644 --- a/Classes/BITStoreButton.h +++ b/Classes/BITStoreButton.h @@ -48,12 +48,35 @@ @end +#ifndef __IPHONE_6_1 +#define __IPHONE_6_1 60100 +#endif + +#if __IPHONE_OS_VERSION_MIN_ALLOWED > __IPHONE_6_1 +#warning Remove the option to adjust the button style. We are now iOS 7 only. +#endif + +/** + * Button style depending on the iOS version + */ +typedef NS_ENUM(NSUInteger, BITStoreButtonStyle) { + /** + * Default is iOS 6 style + */ + BITStoreButtonStyleDefault = 0, + /** + * Draw buttons in the iOS 7 style + */ + BITStoreButtonStyleOS7 = 1 +}; + + // Simulate the Paymeny-Button from the AppStore // The interface is flexible, so there is now fixed order @interface BITStoreButton : UIButton - (id)initWithFrame:(CGRect)frame; -- (id)initWithPadding:(CGPoint)padding; +- (id)initWithPadding:(CGPoint)padding style:(BITStoreButtonStyle)style; // action delegate @property (nonatomic, weak) id buttonDelegate; @@ -64,6 +87,11 @@ // align helper @property (nonatomic, assign) CGPoint customPadding; + +// align helper +@property (nonatomic, assign) BITStoreButtonStyle style; + + - (void)alignToSuperview; @end diff --git a/Classes/BITStoreButton.m b/Classes/BITStoreButton.m index b3405293ae..0fc3e14792 100644 --- a/Classes/BITStoreButton.m +++ b/Classes/BITStoreButton.m @@ -90,7 +90,11 @@ // show white or gray text, depending on the state if (self.buttonData.isEnabled) { - [self setTitleColor:BIT_RGBCOLOR(106, 106, 106) forState:UIControlStateNormal]; + if (self.style == BITStoreButtonStyleDefault) { + [self setTitleColor:BIT_RGBCOLOR(106, 106, 106) forState:UIControlStateNormal]; + } else { + [self setTitleColor:BIT_RGBCOLOR(35, 111, 251) forState:UIControlStateNormal]; + } } else { [self setTitleColor:BIT_RGBCOLOR(148, 150, 151) forState:UIControlStateNormal]; } @@ -149,32 +153,40 @@ // register for touch events [self addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside]; - // main gradient layer - CAGradientLayer *gradient = [CAGradientLayer layer]; - gradient.colors = @[(id)BIT_RGBCOLOR(243, 243, 243).CGColor, (id)BIT_RGBCOLOR(222, 222, 222).CGColor]; - gradient.locations = @[[NSNumber numberWithFloat:0.0], [NSNumber numberWithFloat:1.0]]; - gradient.frame = CGRectMake(0.0, 0.0, CGRectGetWidth(frame), CGRectGetHeight(frame)); - gradient.cornerRadius = 2.5; - gradient.needsDisplayOnBoundsChange = YES; - [self.layer addSublayer:gradient]; - - // border layers for more sex! - CALayer *borderLayer = [CALayer layer]; - borderLayer.borderColor = [BIT_RGBCOLOR(191, 191, 191) CGColor]; - borderLayer.borderWidth = 1.0; - borderLayer.frame = CGRectMake(0.0, 0.0, CGRectGetWidth(frame), CGRectGetHeight(frame)); - borderLayer.cornerRadius = 2.5; - borderLayer.needsDisplayOnBoundsChange = YES; - [self.layer addSublayer:borderLayer]; - [self bringSubviewToFront:self.titleLabel]; } return self; } -- (id)initWithPadding:(CGPoint)padding { - if ((self = [self initWithFrame:CGRectMake(0, 0, 40, BIT_MIN_HEIGHT)])) { +- (id)initWithPadding:(CGPoint)padding style:(BITStoreButtonStyle)style { + CGRect frame = CGRectMake(0, 0, 40, BIT_MIN_HEIGHT); + if ((self = [self initWithFrame:frame])) { _customPadding = padding; + _style = style; + + if (style == BITStoreButtonStyleDefault) { + // main gradient layer + CAGradientLayer *gradient = [CAGradientLayer layer]; + gradient.colors = @[(id)BIT_RGBCOLOR(243, 243, 243).CGColor, (id)BIT_RGBCOLOR(222, 222, 222).CGColor]; + gradient.locations = @[[NSNumber numberWithFloat:0.0], [NSNumber numberWithFloat:1.0]]; + gradient.frame = CGRectMake(0.0, 0.0, CGRectGetWidth(frame), CGRectGetHeight(frame)); + gradient.cornerRadius = 2.5; + gradient.needsDisplayOnBoundsChange = YES; + [self.layer addSublayer:gradient]; + } + + // border layers for more sex! + CALayer *borderLayer = [CALayer layer]; + if (style == BITStoreButtonStyleDefault) { + borderLayer.borderColor = [BIT_RGBCOLOR(191, 191, 191) CGColor]; + } else { + borderLayer.borderColor = [BIT_RGBCOLOR(35, 111, 251) CGColor]; + } + borderLayer.borderWidth = 1.0; + borderLayer.frame = CGRectMake(0.0, 0.0, CGRectGetWidth(frame), CGRectGetHeight(frame)); + borderLayer.cornerRadius = 2.5; + borderLayer.needsDisplayOnBoundsChange = YES; + [self.layer addSublayer:borderLayer]; } return self; } diff --git a/Classes/BITUpdateViewController.m b/Classes/BITUpdateViewController.m index 36bc7634cf..e0ef2d4893 100644 --- a/Classes/BITUpdateViewController.m +++ b/Classes/BITUpdateViewController.m @@ -40,6 +40,7 @@ #import "BITUpdateManagerPrivate.h" #import "BITUpdateViewControllerPrivate.h" +#import "BITHockeyBaseManagerPrivate.h" #define kWebCellIdentifier @"PSWebTableViewCell" @@ -323,7 +324,11 @@ self.tableView.tableHeaderView = _appStoreHeader; - BITStoreButton *storeButton = [[BITStoreButton alloc] initWithPadding:CGPointMake(5, 58)]; + BITStoreButtonStyle buttonStyle = BITStoreButtonStyleDefault; + if (![self.updateManager isPreiOS7Environment]) { + buttonStyle = BITStoreButtonStyleOS7; + } + BITStoreButton *storeButton = [[BITStoreButton alloc] initWithPadding:CGPointMake(5, 58) style:buttonStyle]; storeButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin; storeButton.buttonDelegate = self; [self.tableView.tableHeaderView addSubview:storeButton];