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:
.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.
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")
]
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.