From 1f182205a41c490793d4460a3dee983e055a30fc Mon Sep 17 00:00:00 2001 From: Richard Das Date: Sun, 7 Sep 2014 00:57:48 +0100 Subject: [PATCH 1/2] Only return statusBar height if statusBar is not hidden, else return 0. --- TLYShyNavBar/TLYShyNavBarManager.m | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/TLYShyNavBar/TLYShyNavBarManager.m b/TLYShyNavBar/TLYShyNavBarManager.m index 93ac118..fc764bb 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 From b60827cc1237c773febcaa3d91302657529e1556 Mon Sep 17 00:00:00 2001 From: Richard Das Date: Mon, 8 Sep 2014 13:49:41 +0100 Subject: [PATCH 2/2] fix #31 Added public property for enabling/disabling alpha fade --- TLYShyNavBar/TLYShyNavBarManager.h | 3 +++ TLYShyNavBar/TLYShyNavBarManager.m | 5 ++++- TLYShyNavBar/TLYShyViewController.h | 2 ++ TLYShyNavBar/TLYShyViewController.m | 17 +++++++++++++++-- .../xcshareddata/TLYShyNavBarDemo.xccheckout | 10 +++++----- 5 files changed, 29 insertions(+), 8 deletions(-) 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 fc764bb..7e7c933 100644 --- a/TLYShyNavBar/TLYShyNavBarManager.m +++ b/TLYShyNavBar/TLYShyNavBarManager.m @@ -68,6 +68,8 @@ static inline CGFloat AACStatusBarHeight() self.expansionResistance = 200.f; self.contractionResistance = 0.f; + self.alphaFadeEnabled = YES; + self.previousScrollInsets = UIEdgeInsetsZero; self.previousYOffset = NAN; @@ -224,6 +226,7 @@ static inline CGFloat AACStatusBarHeight() } // 6 - Update the shyViewController + self.navBarController.alphaFadeEnabled = self.alphaFadeEnabled; [self.navBarController updateYOffset:deltaY]; } @@ -239,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