Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: tristanhimmelman/HidingNavigationBar
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.1
Choose a base ref
...
head repository: tristanhimmelman/HidingNavigationBar
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on May 2, 2015

  1. Updated Readme

    tristanhimmelman committed May 2, 2015
    Copy the full SHA
    267b522 View commit details
  2. Copy the full SHA
    7ae5928 View commit details

Commits on May 6, 2015

  1. Updated Readme

    tristanhimmelman committed May 6, 2015
    Copy the full SHA
    7044b8e View commit details

Commits on May 18, 2015

  1. Copy the full SHA
    3e6a86c View commit details

Commits on Sep 22, 2015

  1. swift 2.0 support

    tristanhimmelman committed Sep 22, 2015
    Copy the full SHA
    e5bb63a View commit details
  2. Copy the full SHA
    badae73 View commit details
  3. Copy the full SHA
    10598ee View commit details
  4. Copy the full SHA
    f8fd40f View commit details
  5. merge

    tristanhimmelman committed Sep 22, 2015
    Copy the full SHA
    ef34aa1 View commit details
  6. Updated Readme

    tristanhimmelman committed Sep 22, 2015
    Copy the full SHA
    d38d99f View commit details

Commits on Sep 30, 2015

  1. Copy the full SHA
    41a6e41 View commit details

Commits on Oct 14, 2015

  1. MINOR- fix for issue #6 Section header view below navigation bar afte…

    …r on appearance
    Joel Kopelioff committed Oct 14, 2015
    Copy the full SHA
    e2114aa View commit details
  2. Merge pull request #9 from danieleggert/master

    Respect automaticallyAdjustsScrollViewInsets of owning view controller
    tristanhimmelman committed Oct 14, 2015
    Copy the full SHA
    7acb9a3 View commit details
  3. Merge pull request #11 from jkopelioff/master

    MINOR- fix for issue #6 Section header view below navigation bar afte…
    tristanhimmelman committed Oct 14, 2015
    Copy the full SHA
    ce5443a View commit details
  4. Copy the full SHA
    74976b2 View commit details
  5. - updated podspec

    tristanhimmelman committed Oct 14, 2015
    Copy the full SHA
    d715310 View commit details

Commits on Nov 16, 2015

  1. Copy the full SHA
    b02898a View commit details

Commits on Dec 2, 2015

  1. Merge pull request #16 from joshwalker/master

    make contractionResistance public
    tristanhimmelman committed Dec 2, 2015
    Copy the full SHA
    265035a View commit details

Commits on Dec 9, 2015

  1. fix viewController retain

    - use weak self in closure capture lists
    - change viewController to unowned var
    Ryan Inman committed Dec 9, 2015
    Copy the full SHA
    94d45c4 View commit details

Commits on Jan 14, 2016

  1. Copy the full SHA
    c8a596a View commit details

Commits on Jan 17, 2016

  1. Copy the full SHA
    c7fe9f3 View commit details

Commits on Jan 18, 2016

  1. Copy the full SHA
    c8adda5 View commit details

Commits on Jan 19, 2016

  1. Merge pull request #21 from felipowsky/fix-viewsize

    Enabled extendedLayoutIncludesOpaqueBars
    tristanhimmelman committed Jan 19, 2016
    Copy the full SHA
    fd471bf View commit details
  2. Merge pull request #22 from felipowsky/fix-scrolling

    Fix navigation bar and extension view hiding suddenly
    tristanhimmelman committed Jan 19, 2016
    Copy the full SHA
    5c3bcb1 View commit details

Commits on Feb 12, 2016

  1. Copy the full SHA
    fbe690e View commit details

Commits on Feb 15, 2016

  1. - fixed a strong reference cycle caused by the HidingNavigationBarMan…

    …agerDelegate
    
    - Updated protocol method names
    tristanhimmelman committed Feb 15, 2016
    Copy the full SHA
    5d68ced View commit details
  2. updated podspec

    tristanhimmelman committed Feb 15, 2016
    Copy the full SHA
    3296be6 View commit details
  3. Copy the full SHA
    4c48a2a View commit details

Commits on Apr 15, 2016

  1. - Replace UIApplicationDidBecomeActive with UIApplicationWillEnterFor…

    …eground
    
    - Add options to determine the action to take on foreground event
    Ryan Inman committed Apr 15, 2016
    Copy the full SHA
    9a0a5eb View commit details
  2. Merge pull request #31 from RyanInman/feature/on-foreground-action

    Add Option to Show/Hide NavigationBar + ToolBar on Foreground
    tristanhimmelman committed Apr 15, 2016
    Copy the full SHA
    281bee5 View commit details

Commits on Jun 8, 2016

  1. Added another step to the usage section

    Added import step
    Titouan Van Belle committed Jun 8, 2016
    Copy the full SHA
    67726ae View commit details

Commits on Jun 9, 2016

  1. Merge pull request #34 from TitouanVanBelle/patch-1

    Added another step to the usage section
    tristanhimmelman authored Jun 9, 2016
    Copy the full SHA
    bc1755f View commit details

Commits on Jun 23, 2016

  1. Copy the full SHA
    5372bdb View commit details

Commits on Jul 15, 2016

  1. Merge pull request #40 from kakawamura/master

    Use #selector instead of explicity constructing a Selector
    tristanhimmelman authored Jul 15, 2016
    Copy the full SHA
    86d3c9a View commit details
  2. Merge pull request #25 from ReadmeCritic/master

    Correct the spelling of CocoaPods in README
    tristanhimmelman authored Jul 15, 2016
    Copy the full SHA
    08500bd View commit details
  3. Copy the full SHA
    da14756 View commit details
  4. Copy the full SHA
    5f8d080 View commit details

Commits on Sep 14, 2016

  1. Swift 3 support

    tristanhimmelman committed Sep 14, 2016
    Copy the full SHA
    0268999 View commit details
  2. Updated Podspec and ReadME

    Added .swift-version file for Cocoapods
    tristanhimmelman committed Sep 14, 2016
    Copy the full SHA
    da71479 View commit details

Commits on Sep 30, 2016

  1. Copy the full SHA
    bb462f3 View commit details
  2. fixed mistakes

    rsrbk committed Sep 30, 2016
    Copy the full SHA
    4343264 View commit details

Commits on Mar 2, 2017

  1. Merge pull request #50 from rsrbk/feature/delegate_shouldUpdateScroll…

    …ViewInsets_method
    
    shouldUpdateScrollViewInsets method
    tristanhimmelman authored Mar 2, 2017
    Copy the full SHA
    4e4aa98 View commit details

Commits on Mar 3, 2017

  1. Copy the full SHA
    0aae95c View commit details

Commits on Mar 22, 2017

  1. Remove Gesture when deinit

    Takayoshi Sato committed Mar 22, 2017
    Copy the full SHA
    c0d38c5 View commit details

Commits on Apr 23, 2017

  1. fix readme

    sotozaki committed Apr 23, 2017
    Copy the full SHA
    fb56cf7 View commit details

Commits on Apr 24, 2017

  1. Merge pull request #62 from sotozaki/readme

    fix readme
    tristanhimmelman authored Apr 24, 2017
    Copy the full SHA
    8ae2e77 View commit details

Commits on Sep 14, 2017

  1. upgrade to Swift 4

    jeffaburt committed Sep 14, 2017
    Copy the full SHA
    8792373 View commit details
  2. Copy the full SHA
    08a09b8 View commit details

Commits on Sep 22, 2017

  1. Merge pull request #64 from stockx/jeffaburt/swift-4

    Upgrade to Swift 4
    tristanhimmelman authored Sep 22, 2017
    Copy the full SHA
    5393548 View commit details
  2. Copy the full SHA
    c895ec8 View commit details
Showing with 1,014 additions and 266 deletions.
  1. +1 −0 .swift-version
  2. +2 −2 HidingNavigationBar.podspec
  3. +177 −104 HidingNavigationBar/HidingNavigationBarManager.swift
  4. +56 −32 HidingNavigationBar/HidingViewController.swift
  5. +19 −0 HidingNavigationBarSample/HidingNavigationBar/HidingNavigationBar.h
  6. +26 −0 HidingNavigationBarSample/HidingNavigationBar/Info.plist
  7. +221 −9 HidingNavigationBarSample/HidingNavigationBarSample.xcodeproj/project.pbxproj
  8. +82 −0 ...BarSample/HidingNavigationBarSample.xcodeproj/xcshareddata/xcschemes/HidingNavigationBar.xcscheme
  9. +7 −7 HidingNavigationBarSample/HidingNavigationBarSample/AppDelegate.swift
  10. +11 −9 HidingNavigationBarSample/HidingNavigationBarSample/Base.lproj/Main.storyboard
  11. +82 −0 HidingNavigationBarSample/HidingNavigationBarSample/HiddenNavViewController.swift
  12. +13 −13 HidingNavigationBarSample/HidingNavigationBarSample/HidingNavExtensionViewController.swift
  13. +85 −0 HidingNavigationBarSample/HidingNavigationBarSample/HidingNavShowsNavViewController.swift
  14. +13 −13 HidingNavigationBarSample/HidingNavigationBarSample/HidingNavTabViewController.swift
  15. +11 −11 HidingNavigationBarSample/HidingNavigationBarSample/HidingNavToolbarViewController.swift
  16. +26 −11 HidingNavigationBarSample/HidingNavigationBarSample/HidingNavViewController.swift
  17. +10 −0 HidingNavigationBarSample/HidingNavigationBarSample/Images.xcassets/AppIcon.appiconset/Contents.json
  18. +1 −1 HidingNavigationBarSample/HidingNavigationBarSample/Info.plist
  19. +13 −0 HidingNavigationBarSample/HidingNavigationBarSample/InteractivePopGestureRecognizerDelegate.swift
  20. +26 −21 HidingNavigationBarSample/HidingNavigationBarSample/MasterViewController.swift
  21. +1 −1 HidingNavigationBarSample/HidingNavigationBarSampleTests/HidingNavigationBarSampleTests.swift
  22. +1 −1 HidingNavigationBarSample/HidingNavigationBarSampleTests/Info.plist
  23. +36 −0 HidingNavigationBarSample/HidingNavigationBarTests/HidingNavigationBarTests.swift
  24. +24 −0 HidingNavigationBarSample/HidingNavigationBarTests/Info.plist
  25. +70 −31 README.md
1 change: 1 addition & 0 deletions .swift-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0
4 changes: 2 additions & 2 deletions HidingNavigationBar.podspec
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Pod::Spec.new do |s|

s.name = "HidingNavigationBar"
s.version = "0.2"
s.version = "2.0.1"
s.license = { :type => "MIT", :file => "LICENSE" }
s.summary = "A swift library that manages hiding and showing a Navigation Bar as a user scrolls"
s.homepage = "https://github.com/tristanhimmelman/HidingNavigationBar"
s.author = { "Tristan Himmelman" => "tristanhimmelman@gmail.com" }
s.source = { :git => 'https://github.com/tristanhimmelman/HidingNavigationBar.git', :tag => s.version.to_s }

s.ios.deployment_target = '8.0'
s.requires_arc = 'true'
s.requires_arc = true
s.source_files = 'HidingNavigationBar/**/*.swift'

end
281 changes: 177 additions & 104 deletions HidingNavigationBar/HidingNavigationBarManager.swift

Large diffs are not rendered by default.

88 changes: 56 additions & 32 deletions HidingNavigationBar/HidingViewController.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
//
// HidingViewController.swift
// Optimus
//
// Created by Tristan Himmelman on 2015-03-17.
// Copyright (c) 2015 Hearst TV. All rights reserved.
// The MIT License (MIT)
//
// Copyright (c) 2015 Tristan Himmelman
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import UIKit

@@ -24,36 +41,36 @@ class HidingViewController {
}

init() {
view = UIView(frame: CGRectMake(0, 0, 0, 0))
view.backgroundColor = UIColor.clearColor()
view.autoresizingMask = .FlexibleWidth | .FlexibleBottomMargin
view = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
view.backgroundColor = UIColor.clear
view.autoresizingMask = [.flexibleWidth, .flexibleBottomMargin]
}

func expandedCenterValue() -> CGPoint {
if let expandedCenter = expandedCenter {
return expandedCenter(view)
}
return CGPointMake(0, 0)
return CGPoint(x: 0, y: 0)
}

func contractionAmountValue() -> CGFloat {
return CGRectGetHeight(view.bounds)
return view.bounds.height
}

func contractedCenterValue() -> CGPoint {
if contractsUpwards {
return CGPointMake(expandedCenterValue().x, expandedCenterValue().y - contractionAmountValue())
return CGPoint(x: expandedCenterValue().x, y: expandedCenterValue().y - contractionAmountValue())
} else {
return CGPointMake(expandedCenterValue().x, expandedCenterValue().y + contractionAmountValue())
return CGPoint(x: expandedCenterValue().x, y: expandedCenterValue().y + contractionAmountValue())
}
}

func isContracted() -> Bool {
return Float(fabs(view.center.y - contractedCenterValue().y)) < FLT_EPSILON
return Float(fabs(view.center.y - contractedCenterValue().y)) < .ulpOfOne
}

func isExpanded() -> Bool {
return Float(fabs(view.center.y - expandedCenterValue().y)) < FLT_EPSILON
return Float(fabs(view.center.y - expandedCenterValue().y)) < .ulpOfOne
}

func totalHeight() -> CGFloat {
@@ -64,19 +81,19 @@ class HidingViewController {
return height
}

func setAlphaFadeEnabled(alphaFadeEnabled: Bool) {
func setAlphaFadeEnabled(_ alphaFadeEnabled: Bool) {
self.alphaFadeEnabled = alphaFadeEnabled

if !alphaFadeEnabled {
updateSubviewsToAlpha(1.0)
}
}

func updateYOffset(delta: CGFloat) -> CGFloat {
func updateYOffset(_ delta: CGFloat) -> CGFloat {
var deltaY = delta
if child != nil && deltaY < 0 {
deltaY = child!.updateYOffset(deltaY)
child!.view.hidden = (deltaY) < 0;
child!.view.isHidden = (deltaY) < 0;
}

var newYOffset = view.center.y + deltaY
@@ -86,11 +103,11 @@ class HidingViewController {
newYCenter = min(max(expandedCenterValue().y, newYOffset), contractedCenterValue().y)
}

view.center = CGPointMake(view.center.x, newYCenter)
view.center = CGPoint(x: view.center.x, y: newYCenter)

if alphaFadeEnabled {
var newAlpha: CGFloat = 1.0 - (expandedCenterValue().y - view.center.y) * 2 / contractionAmountValue()
newAlpha = CGFloat(min(max(FLT_EPSILON, Float(newAlpha)), 1.0))
newAlpha = CGFloat(min(max(.ulpOfOne, Float(newAlpha)), 1.0))

updateSubviewsToAlpha(newAlpha)
}
@@ -99,16 +116,16 @@ class HidingViewController {

if (child != nil && deltaY > 0 && residual > 0) {
residual = child!.updateYOffset(residual)
child!.view.hidden = residual - (newYOffset - newYCenter) > 0
child!.view.isHidden = residual - (newYOffset - newYCenter) > 0
}

return residual;
}

func snap(contract: Bool, completion:((Void) -> Void)!) -> CGFloat {
func snap(_ contract: Bool, completion:(() -> Void)!) -> CGFloat {
var deltaY: CGFloat = 0

UIView.animateWithDuration(0.2, delay: 0, options: UIViewAnimationOptions.allZeros, animations: {
UIView.animate(withDuration: 0.2, delay: 0, options: UIViewAnimationOptions(), animations: {
if let child = self.child {
if contract && child.isContracted() {
deltaY = self.contract()
@@ -132,7 +149,7 @@ class HidingViewController {
}

func expand() -> CGFloat {
view.hidden = false
view.isHidden = false

if alphaFadeEnabled {
updateSubviewsToAlpha(1)
@@ -154,34 +171,41 @@ class HidingViewController {
updateSubviewsToAlpha(0)
}

var amountToMove = contractedCenterValue().y - view.center.y
let amountToMove = contractedCenterValue().y - view.center.y

view.center = contractedCenterValue()

return amountToMove;
}

// MARK: - Private methods

private func updateSubviewsToAlpha(alpha: CGFloat) {

// Recursively applies an operation to all views in a view hierarchy
fileprivate func applyToViewHierarchy(rootView: UIView, operation: (UIView) -> Void) {
operation(rootView)
rootView.subviews.forEach { view in
applyToViewHierarchy(rootView: view, operation: operation)
}
}

fileprivate func updateSubviewsToAlpha(_ alpha: CGFloat) {
if navSubviews == nil {
navSubviews = []

// loops through and subview and save the visible ones in navSubviews array
for subView in view.subviews as! [UIView] {
for subView in view.subviews {
let isBackgroundView = subView === view.subviews[0]
let isViewHidden = subView.hidden || Float(subView.alpha) < FLT_EPSILON
let isViewHidden = subView.isHidden || Float(subView.alpha) < .ulpOfOne

if isBackgroundView == false && isViewHidden == false {
navSubviews?.append(subView)
}
}
}

if let subViews = navSubviews {
for subView in subViews {
subView.alpha = alpha
}
}
navSubviews?.forEach { subView in
applyToViewHierarchy(rootView: subView) { view in
view.alpha = alpha
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// HidingNavigationBar.h
// HidingNavigationBar
//
// Created by Tristan Himmelman on 2015-09-22.
// Copyright © 2015 Tristan Himmelman. All rights reserved.
//

#import <UIKit/UIKit.h>

//! Project version number for HidingNavigationBar.
FOUNDATION_EXPORT double HidingNavigationBarVersionNumber;

//! Project version string for HidingNavigationBar.
FOUNDATION_EXPORT const unsigned char HidingNavigationBarVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <HidingNavigationBar/PublicHeader.h>


26 changes: 26 additions & 0 deletions HidingNavigationBarSample/HidingNavigationBar/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6A412A2A1BB1CBA4001C3F67"
BuildableName = "HidingNavigationBar.framework"
BlueprintName = "HidingNavigationBar"
ReferencedContainer = "container:HidingNavigationBarSample.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6A412A2A1BB1CBA4001C3F67"
BuildableName = "HidingNavigationBar.framework"
BlueprintName = "HidingNavigationBar"
ReferencedContainer = "container:HidingNavigationBarSample.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6A412A2A1BB1CBA4001C3F67"
BuildableName = "HidingNavigationBar.framework"
BlueprintName = "HidingNavigationBar"
ReferencedContainer = "container:HidingNavigationBarSample.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -13,33 +13,33 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.

application.setStatusBarStyle(UIStatusBarStyle.LightContent, animated: false)
application.setStatusBarStyle(UIStatusBarStyle.lightContent, animated: false)

return true
}

func applicationWillResignActive(application: UIApplication) {
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(application: UIApplication) {
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(application: UIApplication) {
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(application: UIApplication) {
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(application: UIApplication) {
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7702" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="rS3-R9-Ivy">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="15G1004" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="rS3-R9-Ivy">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Master-->
@@ -24,27 +26,27 @@
<objects>
<tableViewController title="Master" id="pGg-6v-bdr" customClass="MasterViewController" customModule="HidingNavigationBarSample" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="mLL-gJ-YKr">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Cell" textLabel="2pz-XF-uhl" style="IBUITableViewCellStyleDefault" id="m0d-ak-lc9">
<rect key="frame" x="0.0" y="86" width="320" height="44"/>
<rect key="frame" x="0.0" y="86" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="m0d-ak-lc9" id="d3P-M7-ByW">
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
<frame key="frameInset" width="342" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="2pz-XF-uhl">
<rect key="frame" x="15" y="0.0" width="270" height="43"/>
<frame key="frameInset" minX="15" width="325" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</label>
</subviews>
</tableViewCellContentView>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</tableViewCell>
</prototypes>
<sections/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//
// HiddenNavViewController.swift
// HidingNavigationBarSample
//
// Created by asaake on 2017/02/27.
// Copyright (c) 2017 Tristan Himmelman. All rights reserved.
//

import UIKit

class HiddenNavViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {

let identifier = "cell"
var tableView: UITableView!

override func viewDidLoad() {
super.viewDidLoad()

tableView = UITableView(frame: view.bounds)
tableView.dataSource = self
tableView.delegate = self
tableView.register(UITableViewCell.classForCoder(), forCellReuseIdentifier: identifier)
view.addSubview(tableView)
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.setNavigationBarHidden(true, animated: animated)
}

override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
}

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
}

// MARK: UITableViewDelegate

func scrollViewShouldScrollToTop(_ scrollView: UIScrollView) -> Bool {
return true
}

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if indexPath.row == 0 {
dismiss(animated: true, completion: nil)
} else {
let controller = HidingNavShowsNavViewController()
navigationController?.pushViewController(controller, animated: true)
}
}

// MARK: - Table view data source

func numberOfSections(in tableView: UITableView) -> Int {
// #warning Potentially incomplete method implementation.
// Return the number of sections.
return 1
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete method implementation.
// Return the number of rows in the section.
return 100
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath)

// Configure the cell...
if indexPath.row == 0 {
cell.textLabel?.text = "close controller";
cell.selectionStyle = UITableViewCellSelectionStyle.none
} else {
cell.textLabel?.text = "row \((indexPath as NSIndexPath).row)"
cell.selectionStyle = UITableViewCellSelectionStyle.none
}
return cell
}

}
Original file line number Diff line number Diff line change
@@ -20,23 +20,23 @@ class HidingNavExtensionViewController: UIViewController, UITableViewDataSource,
tableView = UITableView(frame: view.bounds)
tableView.dataSource = self
tableView.delegate = self
tableView.registerClass(UITableViewCell.classForCoder(), forCellReuseIdentifier: identifier)
tableView.register(UITableViewCell.classForCoder(), forCellReuseIdentifier: identifier)
view.addSubview(tableView)

let extensionView = UIView(frame: CGRectMake(0, 0, view.frame.size.width, 40))
extensionView.layer.borderColor = UIColor.lightGrayColor().CGColor
let extensionView = UIView(frame: CGRect(x: 0, y: 0, width: view.frame.size.width, height: 40))
extensionView.layer.borderColor = UIColor.lightGray.cgColor
extensionView.layer.borderWidth = 1
extensionView.backgroundColor = UIColor(white: 230/255, alpha: 1)
let label = UILabel(frame: extensionView.frame)
label.text = "Extension View"
label.textAlignment = NSTextAlignment.Center
label.textAlignment = NSTextAlignment.center
extensionView.addSubview(label)

hidingNavBarManager = HidingNavigationBarManager(viewController: self, scrollView: tableView)
hidingNavBarManager?.addExtensionView(extensionView)
}

override func viewWillAppear(animated: Bool) {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
hidingNavBarManager?.viewWillAppear(animated)
}
@@ -46,39 +46,39 @@ class HidingNavExtensionViewController: UIViewController, UITableViewDataSource,
hidingNavBarManager?.viewDidLayoutSubviews()
}

override func viewWillDisappear(animated: Bool) {
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
hidingNavBarManager?.viewWillDisappear(animated)
}

// MARK: UITableViewDelegate

func scrollViewShouldScrollToTop(scrollView: UIScrollView) -> Bool {
func scrollViewShouldScrollToTop(_ scrollView: UIScrollView) -> Bool {
hidingNavBarManager?.shouldScrollToTop()

return true
}

// MARK: - Table view data source

func numberOfSectionsInTableView(tableView: UITableView) -> Int {
func numberOfSections(in tableView: UITableView) -> Int {
// #warning Potentially incomplete method implementation.
// Return the number of sections.
return 1
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete method implementation.
// Return the number of rows in the section.
return 100
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(identifier, forIndexPath: indexPath) as! UITableViewCell
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath)

// Configure the cell...
cell.textLabel?.text = "row \(indexPath.row)"
cell.selectionStyle = UITableViewCellSelectionStyle.None
cell.textLabel?.text = "row \((indexPath as NSIndexPath).row)"
cell.selectionStyle = UITableViewCellSelectionStyle.none

return cell
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
//
// HidingNavShowsNavViewController.swift
// HidingNavigationBarSample
//
// Created by asaake on 2017/02/27.
// Copyright (c) 2017 Tristan Himmelman. All rights reserved.
//

import UIKit

class HidingNavShowsNavViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {

let identifier = "cell"
var hidingNavBarManager: HidingNavigationBarManager?
var tableView: UITableView!

override func viewDidLoad() {
super.viewDidLoad()

tableView = UITableView(frame: view.bounds)
tableView.dataSource = self
tableView.delegate = self
tableView.register(UITableViewCell.classForCoder(), forCellReuseIdentifier: identifier)
view.addSubview(tableView)

let backButton = UIBarButtonItem(title: "Back", style: .plain, target: self, action: #selector(HidingNavShowsNavViewController.backButtonTouched))
navigationItem.leftBarButtonItem = backButton

hidingNavBarManager = HidingNavigationBarManager(viewController: self, scrollView: tableView)
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.setNavigationBarHidden(false, animated: animated)
tableView.panGestureRecognizer.require(toFail: navigationController!.interactivePopGestureRecognizer!)
hidingNavBarManager?.viewWillAppear(animated)
}

override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
hidingNavBarManager?.viewDidLayoutSubviews()
}

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
hidingNavBarManager?.viewWillDisappear(animated)
}

func backButtonTouched(){
_ = navigationController?.popViewController(animated: true)
}

// MARK: UITableViewDelegate

func scrollViewShouldScrollToTop(_ scrollView: UIScrollView) -> Bool {
hidingNavBarManager?.shouldScrollToTop()

return true
}

// MARK: - Table view data source

func numberOfSections(in tableView: UITableView) -> Int {
// #warning Potentially incomplete method implementation.
// Return the number of sections.
return 1
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete method implementation.
// Return the number of rows in the section.
return 100
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath)

// Configure the cell...
cell.textLabel?.text = "row \((indexPath as NSIndexPath).row)"
cell.selectionStyle = UITableViewCellSelectionStyle.none

return cell
}

}
Original file line number Diff line number Diff line change
@@ -21,10 +21,10 @@ class HidingNavTabViewController: UIViewController, UITableViewDataSource, UITab
tableView = UITableView(frame: view.bounds)
tableView.dataSource = self
tableView.delegate = self
tableView.registerClass(UITableViewCell.classForCoder(), forCellReuseIdentifier: identifier)
tableView.register(UITableViewCell.classForCoder(), forCellReuseIdentifier: identifier)
view.addSubview(tableView)

let cancelButton = UIBarButtonItem(title: "Cancel", style: .Plain, target: self, action: Selector("cancelButtonTouched"))
let cancelButton = UIBarButtonItem(title: "Cancel", style: .plain, target: self, action: #selector(HidingNavTabViewController.cancelButtonTouched))
navigationItem.leftBarButtonItem = cancelButton

hidingNavBarManager = HidingNavigationBarManager(viewController: self, scrollView: tableView)
@@ -34,7 +34,7 @@ class HidingNavTabViewController: UIViewController, UITableViewDataSource, UITab
}
}

override func viewWillAppear(animated: Bool) {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
hidingNavBarManager?.viewWillAppear(animated)
}
@@ -44,43 +44,43 @@ class HidingNavTabViewController: UIViewController, UITableViewDataSource, UITab
hidingNavBarManager?.viewDidLayoutSubviews()
}

override func viewWillDisappear(animated: Bool) {
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
hidingNavBarManager?.viewWillDisappear(animated)
}

func cancelButtonTouched(){
navigationController?.dismissViewControllerAnimated(true, completion: nil)
@objc func cancelButtonTouched(){
navigationController?.dismiss(animated: true, completion: nil)
}

// MARK: UITableViewDelegate

func scrollViewShouldScrollToTop(scrollView: UIScrollView) -> Bool {
func scrollViewShouldScrollToTop(_ scrollView: UIScrollView) -> Bool {
hidingNavBarManager?.shouldScrollToTop()

return true
}

// MARK: - Table view data source

func numberOfSectionsInTableView(tableView: UITableView) -> Int {
func numberOfSections(in tableView: UITableView) -> Int {
// #warning Potentially incomplete method implementation.
// Return the number of sections.
return 1
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete method implementation.
// Return the number of rows in the section.
return 100
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(identifier, forIndexPath: indexPath) as! UITableViewCell
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath)

// Configure the cell...
cell.textLabel?.text = "row \(indexPath.row)"
cell.selectionStyle = UITableViewCellSelectionStyle.None
cell.textLabel?.text = "row \((indexPath as NSIndexPath).row)"
cell.selectionStyle = UITableViewCellSelectionStyle.none

return cell
}
Original file line number Diff line number Diff line change
@@ -21,18 +21,18 @@ class HidingNavToolbarViewController: UIViewController, UITableViewDataSource, U
tableView = UITableView(frame: view.bounds)
tableView.dataSource = self
tableView.delegate = self
tableView.registerClass(UITableViewCell.classForCoder(), forCellReuseIdentifier: identifier)
tableView.register(UITableViewCell.classForCoder(), forCellReuseIdentifier: identifier)
view.addSubview(tableView)

toolbar = UIToolbar(frame: CGRectMake(0, view.bounds.size.height - 44, view.bounds.width, 44))
toolbar = UIToolbar(frame: CGRect(x: 0, y: view.bounds.size.height - 44, width: view.bounds.width, height: 44))
toolbar.barTintColor = UIColor(white: 230/255, alpha: 1)
view.addSubview(toolbar)

hidingNavBarManager = HidingNavigationBarManager(viewController: self, scrollView: tableView)
hidingNavBarManager?.manageBottomBar(toolbar)
}

override func viewWillAppear(animated: Bool) {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
hidingNavBarManager?.viewWillAppear(animated)
}
@@ -42,39 +42,39 @@ class HidingNavToolbarViewController: UIViewController, UITableViewDataSource, U
hidingNavBarManager?.viewDidLayoutSubviews()
}

override func viewWillDisappear(animated: Bool) {
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
hidingNavBarManager?.viewWillDisappear(animated)
}

// MARK: UITableViewDelegate

func scrollViewShouldScrollToTop(scrollView: UIScrollView) -> Bool {
func scrollViewShouldScrollToTop(_ scrollView: UIScrollView) -> Bool {
hidingNavBarManager?.shouldScrollToTop()

return true
}

// MARK: - Table view data source

func numberOfSectionsInTableView(tableView: UITableView) -> Int {
func numberOfSections(in tableView: UITableView) -> Int {
// #warning Potentially incomplete method implementation.
// Return the number of sections.
return 1
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete method implementation.
// Return the number of rows in the section.
return 100
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(identifier, forIndexPath: indexPath) as! UITableViewCell
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath)

// Configure the cell...
cell.textLabel?.text = "row \(indexPath.row)"
cell.selectionStyle = UITableViewCellSelectionStyle.None
cell.textLabel?.text = "row \((indexPath as NSIndexPath).row)"
cell.selectionStyle = UITableViewCellSelectionStyle.none

return cell
}
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@

import UIKit

class HidingNavViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
class HidingNavViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, HidingNavigationBarManagerDelegate {

let identifier = "cell"
var hidingNavBarManager: HidingNavigationBarManager?
@@ -20,13 +20,14 @@ class HidingNavViewController: UIViewController, UITableViewDataSource, UITableV
tableView = UITableView(frame: view.bounds)
tableView.dataSource = self
tableView.delegate = self
tableView.registerClass(UITableViewCell.classForCoder(), forCellReuseIdentifier: identifier)
tableView.register(UITableViewCell.classForCoder(), forCellReuseIdentifier: identifier)
view.addSubview(tableView)

hidingNavBarManager = HidingNavigationBarManager(viewController: self, scrollView: tableView)
hidingNavBarManager?.delegate = self
}

override func viewWillAppear(animated: Bool) {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

hidingNavBarManager?.viewWillAppear(animated)
@@ -37,40 +38,54 @@ class HidingNavViewController: UIViewController, UITableViewDataSource, UITableV
hidingNavBarManager?.viewDidLayoutSubviews()
}

override func viewWillDisappear(animated: Bool) {
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
hidingNavBarManager?.viewWillDisappear(animated)
}

// MARK: UITableViewDelegate

func scrollViewShouldScrollToTop(scrollView: UIScrollView) -> Bool {
func scrollViewShouldScrollToTop(_ scrollView: UIScrollView) -> Bool {
hidingNavBarManager?.shouldScrollToTop()

return true
}

// MARK: - UITableViewDataSource

func numberOfSectionsInTableView(tableView: UITableView) -> Int {
func numberOfSections(in tableView: UITableView) -> Int {
// #warning Potentially incomplete method implementation.
// Return the number of sections.
return 1
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete method implementation.
// Return the number of rows in the section.
return 100
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(identifier, forIndexPath: indexPath) as! UITableViewCell
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: identifier, for: indexPath)

// Configure the cell...
cell.textLabel?.text = "row \(indexPath.row)"
cell.selectionStyle = UITableViewCellSelectionStyle.None
cell.textLabel?.text = "row \((indexPath as NSIndexPath).row)"
cell.selectionStyle = UITableViewCellSelectionStyle.none

return cell
}

// MARK: - HidingNavigationBarManagerDelegate

func hidingNavigationBarManagerDidChangeState(_ manager: HidingNavigationBarManager, toState state: HidingNavigationBarState) {

}

func hidingNavigationBarManagerDidUpdateScrollViewInsets(_ manager: HidingNavigationBarManager) {

}

func hidingNavigationBarManagerShouldUpdateScrollViewInsets(_ manager: HidingNavigationBarManager, insets: UIEdgeInsets) -> Bool {
return true
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.tristanhimmelman.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// InteractivePopGestureRecognizerDelegate.swift
// HidingNavigationBarSample
//
// Created by asaake on 2017/03/01.
// Copyright (c) 2017 Tristan Himmelman. All rights reserved.
//

import UIKit

class InteractivePopGestureRecognizerDelegate: NSObject, UIGestureRecognizerDelegate {

}
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import UIKit

class MasterViewController: UITableViewController {

let rows = ["Hiding Nav Bar", "Hiding Nav Bar + Extension View", "Hiding Nav Bar + Toolbar", "Hiding Nav Bar + TabBar"]
let rows = ["Hiding Nav Bar", "Hiding Nav Bar + Extension View", "Hiding Nav Bar + Toolbar", "Hiding Nav Bar + TabBar", "Hidden Shows NavBar + InteractivePopGestureRecognizer"]

override func viewDidLoad() {
super.viewDidLoad()
@@ -21,10 +21,10 @@ class MasterViewController: UITableViewController {
}
}

func styleNavigationController(navigationController: UINavigationController){
navigationController.navigationBar.translucent = true
navigationController.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]
navigationController.navigationBar.tintColor = UIColor.whiteColor()
func styleNavigationController(_ navigationController: UINavigationController){
navigationController.navigationBar.isTranslucent = true
navigationController.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white]
navigationController.navigationBar.tintColor = UIColor.white
navigationController.navigationBar.barTintColor = UIColor(red: 41/255, green: 141/255, blue: 250/255, alpha: 1)
}

@@ -36,50 +36,55 @@ class MasterViewController: UITableViewController {

// MARK: - Table View

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return rows.count
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! UITableViewCell
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)

cell.textLabel?.font = UIFont.systemFontOfSize(16)
cell.textLabel?.text = rows[indexPath.row]
cell.textLabel?.font = UIFont.systemFont(ofSize: 16)
cell.textLabel?.text = rows[(indexPath as NSIndexPath).row]

return cell
}

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: true)
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)

if indexPath.row == 0 {
if (indexPath as NSIndexPath).row == 0 {
let controller = HidingNavViewController()
navigationController?.pushViewController(controller, animated: true)
} else if indexPath.row == 1 {
} else if (indexPath as NSIndexPath).row == 1 {
let controller = HidingNavExtensionViewController()
navigationController?.pushViewController(controller, animated: true)
} else if indexPath.row == 2 {
} else if (indexPath as NSIndexPath).row == 2 {
let controller = HidingNavToolbarViewController()
navigationController?.pushViewController(controller, animated: true)
} else {
} else if (indexPath as NSIndexPath).row == 3 {
let controller1 = HidingNavTabViewController()
let navController1 = UINavigationController(rootViewController: controller1)
navController1.tabBarItem = UITabBarItem(tabBarSystemItem: .MostRecent, tag: 0)
navController1.tabBarItem = UITabBarItem(tabBarSystemItem: .mostRecent, tag: 0)
styleNavigationController(navController1)
let controller2 = HidingNavTabViewController()
let navController2 = UINavigationController(rootViewController: controller2)
navController2.tabBarItem = UITabBarItem(tabBarSystemItem: .Favorites, tag: 1)
navController2.tabBarItem = UITabBarItem(tabBarSystemItem: .favorites, tag: 1)
styleNavigationController(navController2)

let tabBarController = UITabBarController()
tabBarController.viewControllers = [navController1, navController2]
navigationController?.presentViewController(tabBarController, animated: true, completion: nil)
navigationController?.present(tabBarController, animated: true, completion: nil)
} else {
let controller = HiddenNavViewController()
let navController = UINavigationController(rootViewController: controller)
navController.interactivePopGestureRecognizer?.delegate = InteractivePopGestureRecognizerDelegate()
styleNavigationController(navController)
navigationController?.present(navController, animated: true, completion: nil)
}


}
}
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ class HidingNavigationBarSampleTests: XCTestCase {

func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock() {
self.measure() {
// Put the code you want to measure the time of here.
}
}
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.tristanhimmelman.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// HidingNavigationBarTests.swift
// HidingNavigationBarTests
//
// Created by Tristan Himmelman on 2015-09-22.
// Copyright © 2015 Tristan Himmelman. All rights reserved.
//

import XCTest
@testable import HidingNavigationBar

class HidingNavigationBarTests: XCTestCase {

override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}

func testExample() {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}

func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock {
// Put the code you want to measure the time of here.
}
}

}
24 changes: 24 additions & 0 deletions HidingNavigationBarSample/HidingNavigationBarTests/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
101 changes: 70 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
HidingNavigationBar
==============
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![CocoaPods](https://img.shields.io/cocoapods/v/HidingNavigationBar.svg)](https://github.com/tristanhimmelman/HidingNavigationBar)

An easy to use library (written in Swift) that manages hiding and showing a navigation bar as a user scrolls.
- [Features](#features)
- [Usage](#usage)
- [Customization](#customization)
- [Installation](#installation)

#Features
# Features

HidingNavigationBar supports hiding/showing of the following view elements:
- UINavigationBar
- UINavigationBar and an extension UIView
- UINavigationBar and an extension UIView
- UINavigationBar and a UIToolbar
- UINavigationBar and a UITabBar
- UINavigationBar and a UITabBar

###UINavigationBar
### UINavigationBar
![Screenshot](https://raw.githubusercontent.com/tristanhimmelman/HidingNavigationBar/master/screenshots/hidingNav.gif)
###UINavigationBar and an extension UIView
### UINavigationBar and an extension UIView
![Screenshot](https://raw.githubusercontent.com/tristanhimmelman/HidingNavigationBar/master/screenshots/hidingNavExtension.gif)
###UINavigationBar and a UIToolbar
### UINavigationBar and a UIToolbar
![Screenshot](https://raw.githubusercontent.com/tristanhimmelman/HidingNavigationBar/master/screenshots/hidingNavToolbar.gif)
###A UINavigationBar and a UITabBar
### A UINavigationBar and a UITabBar
![Screenshot](https://raw.githubusercontent.com/tristanhimmelman/HidingNavigationBar/master/screenshots/hidingNavTabBar.gif)

#Usage
# Usage

1. Include a member variable of type `HidingNavigationBarManager` in your `UIViewController` subclass.
2. Initialize the variable in `viewDidLoad` function, passing in the `UIViewController` instance and the `UIScrollView` instance that will control the hiding/showing of the navigation bar.
3. Relay the following `UIViewController` lifecycle functions to the `HidingNavigationBarManager` variable:
1. Import HidingNavigationBar
2. Include a member variable of type `HidingNavigationBarManager` in your `UIViewController` subclass.
3. Initialize the variable in `viewDidLoad` function, passing in the `UIViewController` instance and the `UIScrollView` instance that will control the hiding/showing of the navigation bar.
4. Relay the following `UIViewController` lifecycle functions to the `HidingNavigationBarManager` variable:
```swift
override func viewWillAppear(animated: Bool)
override func viewWillDisappear(animated: Bool)
@@ -39,7 +43,9 @@ func scrollViewShouldScrollToTop(scrollView: UIScrollView) -> Bool
```

Below is an example of how your UIViewController subclass should look:
```swift
```swift
import HidingNavigationBar

class MyViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {

var hidingNavBarManager: HidingNavigationBarManager?
@@ -50,55 +56,88 @@ class MyViewController: UIViewController, UITableViewDataSource, UITableViewDele

hidingNavBarManager = HidingNavigationBarManager(viewController: self, scrollView: tableView)
}

override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)

hidingNavBarManager?.viewWillAppear(animated)
}

override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()

hidingNavBarManager?.viewDidLayoutSubviews()
}

override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)

hidingNavBarManager?.viewWillDisappear(animated)
}

//// TableView datasoure and delegate
//// TableView datasoure and delegate

func scrollViewShouldScrollToTop(scrollView: UIScrollView) -> Bool {
hidingNavBarManager?.shouldScrollToTop()

return true
}

...
}
```

Note: HidingNavigationBar only works with UINavigationBars that have translucent set to true.

#Installation
# Customization

### Add an extension view to the UINavigationBar
```swift
let extensionView = // load your a UIView to use as an extension
hidingNavBarManager?.addExtensionView(extensionView)
```
### Hide and show a UITabBar or UIToolbar
```swift
if let tabBar = navigationController?.tabBarController?.tabBar {
hidingNavBarManager?.manageBottomBar(tabBar)
}
```

### Hide/Show/Do Nothing when App is Foregrounded
```swift
hidingNavBarManager?.onForegroundAction = .Default //Do nothing, state of bars will remain the same as when backgrounded
hidingNavBarManager?.onForegroundAction = .Hide //Always hide on foreground
hidingNavBarManager?.onForegroundAction = .Show //Always show on foreground
```

<!--ZoomTransition can be easily added to your project using [Cocoapods](https://cocoapods.org/) by adding the following to your Podfile:-->
### Expansion Resistance
When the navigation bar is hidden, you can some 'resitance' which adds a delay before the navigation bar starts to expand when scrolling. The resistance value is the distance that the user needs to scroll before the navigation bar starts to expand.
```swift
hidingNavBarManager?.expansionResistance = 150
```

<!--`pod 'HidingNavigationBar', '~> 0.1'`-->
### UIRefreshControl

Include the following files directly to your project:
- HidingNavigationBarManager.swift
- HidingViewController.swift
If you are using a UIRefreshControl with your scroll view, it is important to let the `HidingNavigationBarManager` know about it:
```swift
hidingNavBarManager?.refreshControl = refreshControl
```

# Installation

<!--
#Implementation Notes
If your using [Carthage](https://github.com/Carthage/Carthage), add the following line to your Cartfile:
```
github "tristanhimmelman/HidingNavigationBar" ~> 2.0
```

- method swizzling
- tab bar support -->
(for Swift 3, use `github "tristanhimmelman/HidingNavigationBar" ~> 1.0` instead)

If you are using [CocoaPods](https://cocoapods.org/), add the following line to your Podfile:

`pod 'HidingNavigationBar', '~> 2.0'`

(for Swift 3, use `pod 'HidingNavigationBar', '~> 1.0'` instead)

Otherwise, include the following files directly to your project:
- HidingNavigationBarManager.swift
- HidingViewController.swift