Skip to content

Commit

Permalink
Adding AYVibrantButtonStyleInvertWithoutNormalTint configuration du…
Browse files Browse the repository at this point in the history
…e to bug. Noted in code comments.
  • Loading branch information
benguild committed Mar 24, 2016
1 parent 42e156c commit 1a4e7e7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
8 changes: 5 additions & 3 deletions AYVibrantButton/AYVibrantButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -70,7 +71,8 @@ typedef enum {
typedef enum {

AYVibrantButtonOverlayStyleNormal,
AYVibrantButtonOverlayStyleInvert
AYVibrantButtonOverlayStyleInvert,
AYVibrantButtonOverlayStyleNormalWithoutTint // See note above about `AYVibrantButtonStyleInvertWithoutNormalTint`. -@benguild

} AYVibrantButtonOverlayStyle;

Expand Down
17 changes: 10 additions & 7 deletions AYVibrantButton/AYVibrantButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 1a4e7e7

Please sign in to comment.