Skip to content

Commit

Permalink
Added provision for manual gesture recognizer
Browse files Browse the repository at this point in the history
  • Loading branch information
TimOliver committed Sep 14, 2018
1 parent 8d94369 commit 9cd2e0f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions TONavigationBar/TONavigationBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ @interface TONavigationBar ()
// An internal reference to the content view that holds all of visible subviews of the navigation bar
@property (nonatomic, weak) UIView *contentView;

// State tracking for when this bar has captured the parent navigation controller swipe gesture
@property (nonatomic, assign) BOOL navigationControllerGestureCaptured;

@end

@implementation TONavigationBar
Expand Down Expand Up @@ -194,6 +197,11 @@ - (void)updateBackgroundVisibilityForScrollView
self.barStyle = (offsetHeight > barHeight + (statusBarHeight * 0.5f)) ? self.preferredBarStyle : UIBarStyleBlack;
}

- (void)interactivePanGestureRecognized:(UIPanGestureRecognizer *)panRecognizer
{

}

#pragma mark - KVO Handling -
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context
{
Expand Down Expand Up @@ -270,6 +278,16 @@ - (void)setBackgroundHidden:(BOOL)hidden animated:(BOOL)animated forViewControll
}
return;
}

// If not done so, capture the back gesture so we can manually align animations to it
if (!self.navigationControllerGestureCaptured) {
UINavigationController *navController = viewController.navigationController;
if (navController) {
[navController.interactivePopGestureRecognizer addTarget:self action:@selector(interactivePanGestureRecognized:)];
}

self.navigationControllerGestureCaptured = YES;
}

// Apparently parts of the status bar can fail to change color when captured in an interactive transition. So in thoses
// cases, simply flip the bar style outside of the block.
Expand Down

0 comments on commit 9cd2e0f

Please sign in to comment.