Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The way most navigation hiding works is by listening to scroll events from the scroll/table/web view and adjusting the center of the navigation bar.</p> <p>You would make your view controller a delegate of the view in question and apply some level of logic:</p> <pre><code>- (void)scrollViewDidScroll:(UIScrollView *)scrollView { CGFloat scrollOffset = scrollView.contentOffset.y; CGPoint navigationBarCenter = self.navigationController.navigationBar.center; // A bunch of calculations navigationBarCenter.y = newlyCalculatedPosition; self.navigationController.navigationBar.center = navigationBarCenter; } </code></pre> <p>For this specific behavior, they are calculating from where scrolling started and saying "If I'm scrolling down, the navigation bar center should be its original center minus the distance scrolled. If I'm scrolling up, the navigation bar center should be increasing from just off screen to its normal position.</p> <p>You then have to make decisions about what to do when scrolling ends and your nav bar is partly on screen. Do you show it all or just part?</p> <p>Pre-iOS7, you also have to worry about the frame of the scroll view. The iOS7 default behavior is to have view controllers expand to the full size of the device, while the iOS6 default behavior is to fill the space between the nav bar and toolbar. You can address this by using a translucent navigation bar, but will need to adjust your content and scroll indicator insets to limit the content to the inner area when not scrolled.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload