This repository has been archived by the owner on Dec 4, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify code and reorganize project
- Loading branch information
Showing
14 changed files
with
247 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// UIScrollView+Helpers.h | ||
// TLYShyNavBarDemo | ||
// | ||
// Created by Mazyad Alabduljaleel on 11/13/15. | ||
// Copyright © 2015 Telly, Inc. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
|
||
@interface UIScrollView (Helpers) | ||
|
||
- (void)tly_smartSetInsets:(UIEdgeInsets)contentAndScrollIndicatorInsets; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// UIScrollView+Helpers.m | ||
// TLYShyNavBarDemo | ||
// | ||
// Created by Mazyad Alabduljaleel on 11/13/15. | ||
// Copyright © 2015 Telly, Inc. All rights reserved. | ||
// | ||
|
||
#import "UIScrollView+Helpers.h" | ||
|
||
@implementation UIScrollView (Helpers) | ||
|
||
// Modify contentInset and scrollIndicatorInsets while preserving visual content offset | ||
- (void)tly_smartSetInsets:(UIEdgeInsets)contentAndScrollIndicatorInsets | ||
{ | ||
if (contentAndScrollIndicatorInsets.top != self.contentInset.top) | ||
{ | ||
CGPoint contentOffset = self.contentOffset; | ||
contentOffset.y -= contentAndScrollIndicatorInsets.top - self.contentInset.top; | ||
self.contentOffset = contentOffset; | ||
} | ||
|
||
self.contentInset = self.scrollIndicatorInsets = contentAndScrollIndicatorInsets; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// TLYShyParent.h | ||
// TLYShyNavBarDemo | ||
// | ||
// Created by Mazyad Alabduljaleel on 11/13/15. | ||
// Copyright © 2015 Telly, Inc. All rights reserved. | ||
// | ||
|
||
#ifndef TLYShyParent_h | ||
#define TLYShyParent_h | ||
|
||
@protocol TLYShyParent <NSObject> | ||
|
||
@property (nonatomic, readonly) CGFloat viewMaxY; | ||
|
||
- (CGFloat)calculateTotalHeightRecursively; | ||
|
||
@end | ||
|
||
#endif /* TLYShyParent_h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// TLYShyStatusBarController.h | ||
// TLYShyNavBarDemo | ||
// | ||
// Created by Mazyad Alabduljaleel on 11/13/15. | ||
// Copyright © 2015 Telly, Inc. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "TLYShyParent.h" | ||
|
||
|
||
@interface TLYShyStatusBarController : NSObject <TLYShyParent> | ||
|
||
@property (nonatomic, weak) UIViewController *viewController; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// | ||
// TLYShyStatusBarController.m | ||
// TLYShyNavBarDemo | ||
// | ||
// Created by Mazyad Alabduljaleel on 11/13/15. | ||
// Copyright © 2015 Telly, Inc. All rights reserved. | ||
// | ||
|
||
#import "TLYShyStatusBarController.h" | ||
|
||
|
||
// Thanks to SO user, MattDiPasquale | ||
// http://stackoverflow.com/questions/12991935/how-to-programmatically-get-ios-status-bar-height/16598350#16598350 | ||
|
||
static inline CGFloat AACStatusBarHeight(UIViewController *viewController) | ||
{ | ||
if ([UIApplication sharedApplication].statusBarHidden) | ||
{ | ||
return 0.f; | ||
} | ||
|
||
// Modal views do not overlap the status bar, so no allowance need be made for it | ||
CGSize statusBarSize = [UIApplication sharedApplication].statusBarFrame.size; | ||
CGFloat statusBarHeight = MIN(statusBarSize.width, statusBarSize.height); | ||
|
||
UIView *view = viewController.view; | ||
CGRect frame = [view.superview convertRect:view.frame toView:view.window]; | ||
|
||
BOOL viewOverlapsStatusBar = frame.origin.y < statusBarHeight; | ||
|
||
if (!viewOverlapsStatusBar) | ||
{ | ||
return 0.f; | ||
} | ||
|
||
return statusBarHeight; | ||
} | ||
|
||
|
||
@implementation TLYShyStatusBarController | ||
|
||
- (CGFloat)_statusBarHeight | ||
{ | ||
CGFloat statusBarHeight = AACStatusBarHeight(self.viewController); | ||
/* The standard status bar is 20 pixels. The navigation bar extends 20 pixels up so it is overlapped by the status bar. | ||
* When there is a larger than 20 pixel status bar (e.g. a phone call is in progress or GPS is active), the center needs | ||
* to shift up 20 pixels to avoid this 'dead space' being visible above the usual nav bar. | ||
*/ | ||
if (statusBarHeight > 20) | ||
{ | ||
statusBarHeight -= 20; | ||
} | ||
|
||
return statusBarHeight; | ||
} | ||
|
||
- (CGFloat)viewMaxY | ||
{ | ||
return [self _statusBarHeight]; | ||
} | ||
|
||
- (CGFloat)calculateTotalHeightRecursively | ||
{ | ||
return [self _statusBarHeight]; | ||
} | ||
|
||
@end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// TLYShyNavBarFade.h | ||
// TLYShyNavBarDemo | ||
// | ||
// Created by Mazyad Alabduljaleel on 11/13/15. | ||
// Copyright © 2015 Telly, Inc. All rights reserved. | ||
// | ||
|
||
#ifndef TLYShyNavBarFade_h | ||
#define TLYShyNavBarFade_h | ||
|
||
/** This enum helps control the navigation bar fade behavior. | ||
*/ | ||
typedef NS_ENUM(NSInteger, TLYShyNavBarFade) { | ||
|
||
TLYShyNavBarFadeDisabled, | ||
TLYShyNavBarFadeSubviews, | ||
TLYShyNavBarFadeNavbar, | ||
}; | ||
|
||
#endif /* TLYShyNavBarFade_h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.