From 1a4e7e70a69477e090e8e16ddd692683c75621dc Mon Sep 17 00:00:00 2001 From: Ben Guild Date: Thu, 24 Mar 2016 17:30:40 +0900 Subject: [PATCH] Adding `AYVibrantButtonStyleInvertWithoutNormalTint` configuration due to bug. Noted in code comments. --- AYVibrantButton/AYVibrantButton.h | 8 +++++--- AYVibrantButton/AYVibrantButton.m | 17 ++++++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/AYVibrantButton/AYVibrantButton.h b/AYVibrantButton/AYVibrantButton.h index b8fc6f8..1c66d05 100644 --- a/AYVibrantButton/AYVibrantButton.h +++ b/AYVibrantButton/AYVibrantButton.h @@ -34,8 +34,9 @@ typedef enum { AYVibrantButtonStyleInvert, AYVibrantButtonStyleTranslucent, - AYVibrantButtonStyleFill - + AYVibrantButtonStyleFill, + AYVibrantButtonStyleInvertWithoutNormalTint // NOTE: I was experiencing a bug with it drawing borders around the icons. Since I didn't need tint in a normal state, I created this to disable it until the bug is fixed. -@benguild + } AYVibrantButtonStyle; @interface AYVibrantButton : UIButton @@ -70,7 +71,8 @@ typedef enum { typedef enum { AYVibrantButtonOverlayStyleNormal, - AYVibrantButtonOverlayStyleInvert + AYVibrantButtonOverlayStyleInvert, + AYVibrantButtonOverlayStyleNormalWithoutTint // See note above about `AYVibrantButtonStyleInvertWithoutNormalTint`. -@benguild } AYVibrantButtonOverlayStyle; diff --git a/AYVibrantButton/AYVibrantButton.m b/AYVibrantButton/AYVibrantButton.m index a3a8c8f..c0f0633 100644 --- a/AYVibrantButton/AYVibrantButton.m +++ b/AYVibrantButton/AYVibrantButton.m @@ -148,17 +148,19 @@ - (void)createOverlays { if (self.style == AYVibrantButtonStyleFill) { self.normalOverlay = [[AYVibrantButtonOverlay alloc] initWithStyle:AYVibrantButtonOverlayStyleInvert]; + } else if (self.style == AYVibrantButtonStyleInvertWithoutNormalTint) { + self.normalOverlay = [[AYVibrantButtonOverlay alloc] initWithStyle:AYVibrantButtonOverlayStyleNormalWithoutTint]; } else { self.normalOverlay = [[AYVibrantButtonOverlay alloc] initWithStyle:AYVibrantButtonOverlayStyleNormal]; } - - if (self.style == AYVibrantButtonStyleInvert) { + + if (self.style == AYVibrantButtonStyleInvert || self.style == AYVibrantButtonStyleInvertWithoutNormalTint) { self.highlightedOverlay = [[AYVibrantButtonOverlay alloc] initWithStyle:AYVibrantButtonOverlayStyleInvert]; self.highlightedOverlay.alpha = 0.0; } else if (self.style == AYVibrantButtonStyleTranslucent || self.style == AYVibrantButtonStyleFill) { self.normalOverlay.alpha = self.translucencyAlphaNormal * self.alpha; } - + #ifndef __IPHONE_8_0 // for iOS 8, these two overlay views will be added as subviews in setVibrancyEffect: [self addSubview:self.normalOverlay]; @@ -174,7 +176,7 @@ - (void)touchDown { self.activeTouch = YES; void(^update)(void) = ^(void) { - if (self.style == AYVibrantButtonStyleInvert) { + if (self.style == AYVibrantButtonStyleInvert || self.style == AYVibrantButtonStyleInvertWithoutNormalTint) { self.normalOverlay.alpha = 0.0; self.highlightedOverlay.alpha = self.alpha; } else if (self.style == AYVibrantButtonStyleTranslucent || self.style == AYVibrantButtonStyleFill) { @@ -194,7 +196,7 @@ - (void)touchUp { self.activeTouch = NO; void(^update)(void) = ^(void) { - if (self.style == AYVibrantButtonStyleInvert) { + if (self.style == AYVibrantButtonStyleInvert || self.style == AYVibrantButtonStyleInvertWithoutNormalTint) { self.normalOverlay.alpha = self.alpha; self.highlightedOverlay.alpha = 0.0; } else if (self.style == AYVibrantButtonStyleTranslucent || self.style == AYVibrantButtonStyleFill) { @@ -222,20 +224,21 @@ - (void)setAlpha:(CGFloat)alpha { _alpha = alpha; if (self.activeTouch) { - if (self.style == AYVibrantButtonStyleInvert) { + if (self.style == AYVibrantButtonStyleInvert || self.style == AYVibrantButtonStyleInvertWithoutNormalTint) { self.normalOverlay.alpha = 0.0; self.highlightedOverlay.alpha = self.alpha; } else if (self.style == AYVibrantButtonStyleTranslucent || self.style == AYVibrantButtonStyleFill) { self.normalOverlay.alpha = self.translucencyAlphaHighlighted * self.alpha; } } else { - if (self.style == AYVibrantButtonStyleInvert) { + if (self.style == AYVibrantButtonStyleInvert || self.style == AYVibrantButtonStyleInvertWithoutNormalTint) { self.normalOverlay.alpha = self.alpha; self.highlightedOverlay.alpha = 0.0; } else if (self.style == AYVibrantButtonStyleTranslucent || self.style == AYVibrantButtonStyleFill) { self.normalOverlay.alpha = self.translucencyAlphaNormal * self.alpha; } } + } - (void)setCornerRadius:(CGFloat)cornerRadius {