Added ability to alphaFade entire navbar instead of just it's subviews. Transfered userInteractionEnabled state from extensionView to extensionViewContainer.

This commit is contained in:
Nicholas Long 2015-10-08 11:51:19 -07:00
parent a05054d7df
commit e5ef717aaf
4 changed files with 13 additions and 4 deletions

View File

@ -56,6 +56,7 @@
* Defaults to YES
*/
@property (nonatomic, getter = isAlphaFadeEnabled) BOOL alphaFadeEnabled;
@property (nonatomic, getter = isAlphaFadeEntireNavBarEnabled) BOOL alphaFadeEntireNavBar;
@property (nonatomic) BOOL disable;

View File

@ -100,6 +100,7 @@ static void * const kTLYShyNavBarManagerKVOContext = (void*)&kTLYShyNavBarManage
self.contractionResistance = 0.f;
self.alphaFadeEnabled = YES;
self.alphaFadeEntireNavBar = NO;
self.previousScrollInsets = UIEdgeInsetsZero;
self.previousYOffset = NAN;
@ -320,6 +321,7 @@ static void * const kTLYShyNavBarManagerKVOContext = (void*)&kTLYShyNavBarManage
// 6 - Update the shyViewController
self.navBarController.alphaFadeEnabled = self.alphaFadeEnabled;
self.navBarController.alphaFadeEntireNavBar = self.alphaFadeEntireNavBar;
[self.navBarController updateYOffset:deltaY];
}
@ -382,6 +384,7 @@ static void * const kTLYShyNavBarManagerKVOContext = (void*)&kTLYShyNavBarManage
self.extensionViewContainer.frame = bounds;
[self.extensionViewContainer addSubview:view];
self.extensionViewContainer.userInteractionEnabled = view.userInteractionEnabled;
/* Disable scroll handling temporarily while laying out views to avoid double-changing content
* offsets in _handleScrolling. */

View File

@ -37,6 +37,7 @@ typedef CGFloat(^TLYShyViewControllerContractionAmountBlock)(UIView *view);
@property (nonatomic) BOOL hidesAfterContraction;
@property (nonatomic) BOOL alphaFadeEnabled;
@property (nonatomic) BOOL alphaFadeEntireNavBar;
@property (nonatomic, readonly) CGFloat totalHeight;

View File

@ -61,8 +61,12 @@ const CGFloat contractionVelocity = 300.f;
// This method is courtesy of GTScrollNavigationBar
// https://github.com/luugiathuy/GTScrollNavigationBar
- (void)_updateSubviewsToAlpha:(CGFloat)alpha
- (void)_updateViewsToAlpha:(CGFloat)alpha
{
if (_alphaFadeEntireNavBar) {
self.view.alpha = alpha;
}
for (UIView* view in self.view.subviews)
{
bool isBackgroundView = view == self.view.subviews[0];
@ -83,7 +87,7 @@ const CGFloat contractionVelocity = 300.f;
if (!alphaFadeEnabled)
{
[self _updateSubviewsToAlpha:1.f];
[self _updateViewsToAlpha:1.f];
}
}
@ -113,7 +117,7 @@ const CGFloat contractionVelocity = 300.f;
if (self.alphaFadeEnabled)
{
[self _updateSubviewsToAlpha:newAlpha];
[self _updateViewsToAlpha:newAlpha];
}
}
@ -163,7 +167,7 @@ const CGFloat contractionVelocity = 300.f;
if (self.hidesSubviews && self.alphaFadeEnabled)
{
[self _updateSubviewsToAlpha:1.f];
[self _updateViewsToAlpha:1.f];
}
CGFloat amountToMove = self.expandedCenterValue.y - self.view.center.y;