diff --git a/TLYShyNavBar/TLYShyNavBarManager.h b/TLYShyNavBar/TLYShyNavBarManager.h index 878e106..4bacec5 100644 --- a/TLYShyNavBar/TLYShyNavBarManager.h +++ b/TLYShyNavBar/TLYShyNavBarManager.h @@ -47,6 +47,9 @@ @property (nonatomic) CGFloat expansionResistance; // default 200 @property (nonatomic) CGFloat contractionResistance; // default 0 +/* Turn on or off the alpha fade as the navbar contracts/expands. Defaults to YES */ +@property (nonatomic) BOOL alphaFadeEnabled; + @end diff --git a/TLYShyNavBar/TLYShyNavBarManager.m b/TLYShyNavBar/TLYShyNavBarManager.m index 93ac118..7e7c933 100644 --- a/TLYShyNavBar/TLYShyNavBarManager.m +++ b/TLYShyNavBar/TLYShyNavBarManager.m @@ -22,8 +22,12 @@ static inline CGFloat AACStatusBarHeight() { - CGSize statusBarSize = [UIApplication sharedApplication].statusBarFrame.size; - return MIN(statusBarSize.width, statusBarSize.height); + if ([UIApplication sharedApplication].statusBarHidden == NO){ + CGSize statusBarSize = [UIApplication sharedApplication].statusBarFrame.size; + return MIN(statusBarSize.width, statusBarSize.height); + } else { + return 0.f; + } } #pragma mark - TLYShyNavBarManager class @@ -64,6 +68,8 @@ static inline CGFloat AACStatusBarHeight() self.expansionResistance = 200.f; self.contractionResistance = 0.f; + self.alphaFadeEnabled = YES; + self.previousScrollInsets = UIEdgeInsetsZero; self.previousYOffset = NAN; @@ -220,6 +226,7 @@ static inline CGFloat AACStatusBarHeight() } // 6 - Update the shyViewController + self.navBarController.alphaFadeEnabled = self.alphaFadeEnabled; [self.navBarController updateYOffset:deltaY]; } @@ -235,7 +242,7 @@ static inline CGFloat AACStatusBarHeight() self.resistanceConsumed = 0; - CGFloat deltaY = deltaY = [self.navBarController snap:self.isContracting]; + CGFloat deltaY = [self.navBarController snap:self.isContracting]; CGPoint newContentOffset = self.scrollView.contentOffset; newContentOffset.y -= deltaY; diff --git a/TLYShyNavBar/TLYShyViewController.h b/TLYShyNavBar/TLYShyViewController.h index 1a7451d..6321879 100644 --- a/TLYShyNavBar/TLYShyViewController.h +++ b/TLYShyNavBar/TLYShyViewController.h @@ -35,6 +35,8 @@ typedef CGFloat(^TLYShyViewControllerContractionAmountBlock)(UIView *view); @property (nonatomic) BOOL hidesSubviews; @property (nonatomic) BOOL hidesAfterContraction; +@property (nonatomic) BOOL alphaFadeEnabled; + @property (nonatomic, readonly) CGFloat totalHeight; - (CGFloat)updateYOffset:(CGFloat)deltaY; diff --git a/TLYShyNavBar/TLYShyViewController.m b/TLYShyNavBar/TLYShyViewController.m index b09f610..1fb0369 100644 --- a/TLYShyNavBar/TLYShyViewController.m +++ b/TLYShyNavBar/TLYShyViewController.m @@ -77,6 +77,16 @@ const CGFloat contractionVelocity = 300.f; #pragma mark - Public methods +- (void)setAlphaFadeEnabled:(BOOL)alphaFadeEnabled +{ + _alphaFadeEnabled = alphaFadeEnabled; + + if (!alphaFadeEnabled) + { + [self _updateSubviewsToAlpha:1.f]; + } +} + - (CGFloat)updateYOffset:(CGFloat)deltaY { if (self.child && deltaY < 0) @@ -95,7 +105,10 @@ const CGFloat contractionVelocity = 300.f; CGFloat newAlpha = 1.f - (self.expandedCenterValue.y - self.view.center.y) / self.contractionAmountValue; newAlpha = MIN(MAX(FLT_EPSILON, newAlpha), 1.f); - [self _updateSubviewsToAlpha:newAlpha]; + if (self.alphaFadeEnabled) + { + [self _updateSubviewsToAlpha:newAlpha]; + } } CGFloat residual = newYOffset - newYCenter; @@ -142,7 +155,7 @@ const CGFloat contractionVelocity = 300.f; { self.view.hidden = NO; - if (self.hidesSubviews) + if (self.hidesSubviews && self.alphaFadeEnabled) { [self _updateSubviewsToAlpha:1.f]; } diff --git a/TLYShyNavBarDemo/TLYShyNavBarDemo.xcodeproj/project.xcworkspace/xcshareddata/TLYShyNavBarDemo.xccheckout b/TLYShyNavBarDemo/TLYShyNavBarDemo.xcodeproj/project.xcworkspace/xcshareddata/TLYShyNavBarDemo.xccheckout index de873da..899360e 100644 --- a/TLYShyNavBarDemo/TLYShyNavBarDemo.xcodeproj/project.xcworkspace/xcshareddata/TLYShyNavBarDemo.xccheckout +++ b/TLYShyNavBarDemo/TLYShyNavBarDemo.xcodeproj/project.xcworkspace/xcshareddata/TLYShyNavBarDemo.xccheckout @@ -10,29 +10,29 @@ TLYShyNavBarDemo IDESourceControlProjectOriginsDictionary - A10EB39B-4D27-4420-B35D-3615C3072AE6 + 58D55ECABAD5AAEB583BB3898420091CC2A418B2 ssh://github.com/telly/TLYShyNavBar.git IDESourceControlProjectPath TLYShyNavBarDemo/TLYShyNavBarDemo.xcodeproj/project.xcworkspace IDESourceControlProjectRelativeInstallPathDictionary - A10EB39B-4D27-4420-B35D-3615C3072AE6 + 58D55ECABAD5AAEB583BB3898420091CC2A418B2 ../../.. IDESourceControlProjectURL ssh://github.com/telly/TLYShyNavBar.git IDESourceControlProjectVersion - 110 + 111 IDESourceControlProjectWCCIdentifier - A10EB39B-4D27-4420-B35D-3615C3072AE6 + 58D55ECABAD5AAEB583BB3898420091CC2A418B2 IDESourceControlProjectWCConfigurations IDESourceControlRepositoryExtensionIdentifierKey public.vcs.git IDESourceControlWCCIdentifierKey - A10EB39B-4D27-4420-B35D-3615C3072AE6 + 58D55ECABAD5AAEB583BB3898420091CC2A418B2 IDESourceControlWCCName TLYShyNavBar