Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions NJKScrollFullScreen/UIViewController+NJKFullScreenSupport.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

#import "UIViewController+NJKFullScreenSupport.h"

#define kNearZero 0.000001f

@implementation UIViewController (NJKFullScreenSupport)

- (void)showNavigationBar:(BOOL)animated
Expand Down Expand Up @@ -49,12 +51,15 @@ - (void)setNavigationBarOriginY:(CGFloat)y animated:(BOOL)animated
CGFloat bottomLimit = statusBarHeight;

frame.origin.y = fmin(fmax(y, topLimit), bottomLimit);
CGFloat alpha = 1 - (statusBarHeight - frame.origin.y) / statusBarHeight;
UIColor *titleTextColor = self.navigationController.navigationBar.titleTextAttributes[NSForegroundColorAttributeName] ?: [UIColor blackColor];
titleTextColor = [titleTextColor colorWithAlphaComponent:alpha]; // fade title
CGFloat alpha = MAX(1 - (statusBarHeight - frame.origin.y) / statusBarHeight, kNearZero);
[UIView animateWithDuration:animated ? 0.1 : 0 animations:^{
self.navigationController.navigationBar.frame = frame;
[self.navigationController.navigationBar setTitleTextAttributes:@{ NSForegroundColorAttributeName : titleTextColor }];
NSUInteger index = 0;
for (UIView *view in self.navigationController.navigationBar.subviews) {
index++;
if (index == 1 || view.hidden || view.alpha <= 0.0f) continue;
view.alpha = alpha;
}
if (NJK_IS_RUNNING_IOS7) {
// fade bar buttons
UIColor *tintColor = self.navigationController.navigationBar.tintColor;
Expand All @@ -63,7 +68,6 @@ - (void)setNavigationBarOriginY:(CGFloat)y animated:(BOOL)animated
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:components[0] green:components[1] blue:components[2] alpha:alpha];
}
}

}];
}

Expand Down