A simple UIProgressView attachs to top of UINavigationController
.oneTime | .always | |
---|---|---|
push | ||
present fullscreen | ||
present overCurrentContext |
- iOS 10+
- Swift 5.0+
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift
compiler. It is in early development, but Gradient Progress Bar does support its use on supported platforms.
Once you have your Swift package set up, adding Gradient Progress Bar 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.1")
]
Import NavigationProgress
when you need.
import NavigationProgress
Call setup()
once your app start to enable the swizzleHelper to make NavigationProgress work properly
NavigationProgress.setup()
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 the existing NavigationProgress from your navigationController
removeNavigationProgress()
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
Adjusts the total number of pages, used for calculate the total value for progressBarView.
navigationProgress.totalPages = 3
Set NavigationProgress
progress type for only display for oneTime
or always
NavigationProgress will be removed after passed the totalPages
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
}
Adjusts the color shown for the portion of the progress bar that is filled.
navigationProgress.progressTintColor = .orange
Adjusts the color shown for the portion of the progress bar that is not filled.
navigationProgress.trackTintColor = .gray
Adjusts animation duration for show / hide NavigationProgress once it is added or removed
navigationProgress.animationDuration = 0.3
Chris Ng (chrisnyw(@)gmail.com)
NavigationProgress is available under the MIT license. See the LICENSE file for more info.