Merge pull request #32 from richarddas/master
fix #31 Added public property for enabling/disabling alpha fade
This commit is contained in:
commit
1bca61f0f6
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,29 +10,29 @@
|
|||
<string>TLYShyNavBarDemo</string>
|
||||
<key>IDESourceControlProjectOriginsDictionary</key>
|
||||
<dict>
|
||||
<key>A10EB39B-4D27-4420-B35D-3615C3072AE6</key>
|
||||
<key>58D55ECABAD5AAEB583BB3898420091CC2A418B2</key>
|
||||
<string>ssh://github.com/telly/TLYShyNavBar.git</string>
|
||||
</dict>
|
||||
<key>IDESourceControlProjectPath</key>
|
||||
<string>TLYShyNavBarDemo/TLYShyNavBarDemo.xcodeproj/project.xcworkspace</string>
|
||||
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
|
||||
<dict>
|
||||
<key>A10EB39B-4D27-4420-B35D-3615C3072AE6</key>
|
||||
<key>58D55ECABAD5AAEB583BB3898420091CC2A418B2</key>
|
||||
<string>../../..</string>
|
||||
</dict>
|
||||
<key>IDESourceControlProjectURL</key>
|
||||
<string>ssh://github.com/telly/TLYShyNavBar.git</string>
|
||||
<key>IDESourceControlProjectVersion</key>
|
||||
<integer>110</integer>
|
||||
<integer>111</integer>
|
||||
<key>IDESourceControlProjectWCCIdentifier</key>
|
||||
<string>A10EB39B-4D27-4420-B35D-3615C3072AE6</string>
|
||||
<string>58D55ECABAD5AAEB583BB3898420091CC2A418B2</string>
|
||||
<key>IDESourceControlProjectWCConfigurations</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
|
||||
<string>public.vcs.git</string>
|
||||
<key>IDESourceControlWCCIdentifierKey</key>
|
||||
<string>A10EB39B-4D27-4420-B35D-3615C3072AE6</string>
|
||||
<string>58D55ECABAD5AAEB583BB3898420091CC2A418B2</string>
|
||||
<key>IDESourceControlWCCName</key>
|
||||
<string>TLYShyNavBar</string>
|
||||
</dict>
|
||||
|
|
|
|||
Loading…
Reference in New Issue