iOS UI library to show and hide an extension to your UINavigationBar

ADNavigationBarExtension

ADNavigationBarExtension is a UI library written in Swift. It allows you to show and hide an extension to your UINavigationBar.

Features

Use ExtensibleNavigationBarNavigationController to set an extension under your UINavigationBar:

  • The navigation controller manages the displaying of your navigation bar's extension
  • It is compatible with UIAppearance

See the provided examples for help or feel free to ask directly.


Requirements

ADNavigationBarExtension is written in swift 5.0. Compatible with iOS 10.0+

Installation

OverlayContainer is available through CocoaPods. To install it, simply add the following line to your Podfile:

Cocoapods

pod 'ADNavigationBarExtension'

Usage

Setup

The main component of the library is the ExtensibleNavigationBarNavigationController.
It is basicaly a simple UINavigationController wich manages a supplementary view under the UINavigationBar.

A startup sequence might look like this:

let navigationController = ExtensibleNavigationBarNavigationController()
let navigationBarExtension = MyCustomView()
let navigationBarExtensionHeight = 64
navigationController.setNavigationBarExtensionView(navigationBarExtension, forHeight: navigationBarExtensionHeight)
navigationController.pushViewController(MyViewController(), animated: false)
window.rootViewController = navigationController

Then the ExtensibleNavigationBarNavigationController needs to know when the navigation bar's extension needs
to be displayed or to be hidden.
You have to use the protocol ExtensibleNavigationBarInformationProvider:

extension MyViewController: ExtensibleNavigationBarInformationProvider {
    var shouldExtendNavigationBar: Bool { return true }
}

Warning

Be aware of ExtensibleNavigationBarNavigationController is using the UINavigationControllerDelegate protocol.
So if you also need to use de navigationController's delegate proprerty, you can use this:

let navigationController = ExtensibleNavigationBarNavigationController()
navigationController.navigationControllerDelegate = self

There is an issue with iOS 12 where the isTranslucent property cannot be retrieved from the
UINavigationBar.appearance() method.
So if you need to set your UINavigationBar translucent, you can use this:

ExtensibleNavigationBarNavigationController.ad_isTranslucent = true

GitHub