Swiftpack.co - Package - CanopyTax/GradientNavigationBar

Carthage compatible


alt text

GradientNavigationBar is a drop in subclass of UINavigationBar that easily allows you to set the background to be a gradient. It supports SafeAreaLayoutGuide so it looks great on iPhone X and 3rd generation iPad Pro devices.


  • iOS 9.0+
  • Xcode 10.0+
  • Swift 4.2+



Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate GradientNavigationBar into your Xcode project using Carthage, specify it in your Cartfile:

github "CanopyTax/GradientNavigationBar" ~> 0.2.0

Run carthage update to build the framework and drag the built GradientNavigationBar.framework into your Xcode project.


Coming Soon


If you prefer not to use either of the aforementioned dependency managers, you can integrate GradientNavigationBar into your project manually.


Quick Start

Initialize GradientNavigationBar with a rootViewController:

let gradientNavigationController = GradientNavigationBar(rootViewController: ViewController())
// Set gradient colors
gradientNavigationController.gradientColors = [GradientNavigationBarColor(color: UIColor.blue, location: 0.0),
                                               GradientNavigationBarColor(color: UIColor.purple, location: 1.0)]

Other properties can be set including headerFont, titleFont, and foregroundColor

In most cases, you can interact with GradientNavigationBar in the same way you use UINavigationController

class MyViewController: UIViewController {
    override func viewDidLoad() {
        // Set a single title
        self.title = "My View Title"
        // Set a title with a header
        self.navigationItem.setTitle(title: "Title", header: "Header", navigationController: navigationController)

        // Create button items
        let addBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(addButtonPressed))
        let randomBarButtonItem = UIBarButtonItem(barButtonSystemItem: .refresh, target: self, action: #selector(randomButtonPressed))

        // Set button items
        self.navigationItem.setRightBarButtonItems([addBarButtonItem, randomBarButtonItem], animated: true)
    @objc func addButtonPressed() {
        navigationController?.pushViewController(ViewController(), animated: true)
    @objc func randomButtonPressed() {
        // ...


GradientNavigationBar is released under the MIT license. See LICENSE for details.


Stars: 3


Used By

Total: 0


0.8.0 - 2020-09-16 20:58:44

Add support for Swift Package Manager

v0.7.0 - 2020-05-05 22:23:55

Adds open spacing property so that the spacing between the header and title can be overridden. Default adjusted to 0 (from -5 in v0.5.0 and -2 in v0.6.0)

v0.6.0 - 2020-05-05 21:48:03

Added some more spacing between title and subtitle to play nicer with a wider range of fonts.

v0.5.0 - 2019-11-13 23:09:57

Reverted formatting change from v0.4.0 for header/subheader layout

v0.3.0 - 2019-06-07 17:16:36

This release resolves and issue with colors conflicting between multiple instances of GradientNavigationBar. While this release doesn't break existing code, it is important to note, that setTitle does have an additional optional parameter navigationBar: UINavigationBar?. If this is not set, a default font and color will be used instead of any custom ones that may have been set on GradientNavigationBar.