Skip to content

A simple UIProgressView attachs to top of UINavigationController

License

Notifications You must be signed in to change notification settings

chrisnyw/NavigationProgress

Repository files navigation

NavigationProgress

SwiftVersion Platform License: MIT

A simple way to make UIProgressView attach to top of UINavigationController.

import NavigationProgress

NavigationProgress.setup()
startNavigationProgress(with: NavigationProgress(totalPages: 3))

All done, and you can have this: sample


.oneTime .always
push
present fullscreen
present overCurrentContext

Requirements

  • iOS 10+
  • Swift 5.0+

Installation

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, adding NavigationProgress as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/chrisnyw/NavigationProgress", from: "0.2")
]

How to use

- Import NavigationProgress

Import NavigationProgress when you need.

import NavigationProgress

– NavigationProgress setup

Call setup() once your app start to enable the swizzleHelper to make NavigationProgress work properly

NavigationProgress.setup()

- start NavigationProgress in your UIViewController

Ensure your UIViewController is under UINavigationController, and calls startNavigationProgress(with:) in your current viewController class. Once your call startNavigationProgress(), it treats your current page is first page and NavigationProgress will be shown. Meanwhile, when your back to your previous page, NavigationProgress will be remove from your navigationController.

startNavigationProgress(with: NavigationProgress(totalPages: 3))

- force remove NavigationProgres

Force remove the existing NavigationProgress from your navigationController

removeNavigationProgress()

Configuration

- Object NavigationProgress

totalPages is the only compulsory property for object NavigationProgress

NavigationProgress(totalPages: 3)

Or you may configure NavigationProgress by passing all values

NavigationProgress(totalPages: 3,
                   progressType: .oneTime, // default .oneTime
                   progressTintColor: .orange, // default .orange
                   trackTintColor: .gray, // default .gray
                   animationDuration: 0.3) // default 0.3

– Property totalPages

Adjusts the total number of pages, used for calculate the total value for progressBarView.

navigationProgress.totalPages = 3

– Property progressType

Set NavigationProgress progress type for only display for oneTime or always

- .oneTime

NavigationProgress will be removed after passed the totalPages

- .oneTime

NavigationProgress will not be removed after passed the totalPages. Thus, when you back to page before totalPages NavigationProgress will be shown again.

public enum ProgressType {
  case oneTime
  case always
}

– Property progressTintColor

Adjusts the color shown for the portion of the progress bar that is filled.

navigationProgress.progressTintColor = .orange

– Property trackTintColor

Adjusts the color shown for the portion of the progress bar that is not filled.

navigationProgress.trackTintColor = .gray

– Property animationDuration

Adjusts animation duration for show / hide NavigationProgress once it is added or removed

navigationProgress.animationDuration = 0.3

Author

Chris Ng (chrisnyw@gmail.com)


License

NavigationProgress is available under the MIT license. See the LICENSE file for more info.

About

A simple UIProgressView attachs to top of UINavigationController

Resources

License

Stars

Watchers

Forks

Packages

No packages published