一个简单的UIProgressView附加到UINavigationController的顶部
导航进度
一个简单的UIProgressView附加到UINavigationController的顶部
.oneTime innavigationController
.始终从模态视图navigationController
要求
- iOS 10+
- 斯威夫特 5.0+
安装
Swift Package Manager
Swift Package Manager 是一个用于自动分发 Swift 代码的工具,并集成到编译器中。它处于早期开发阶段,但渐变进度条确实支持在支持的平台上使用它。swift
设置 Swift 包后,将渐变进度条添加为依赖项就像将其添加到 .dependencies
Package.swift
dependencies: [
.package(url: "https://github.com/chrisnyw/NavigationProgress", from: "0.1")
]
如何使用
– 导入导航进度
在需要时导入。NavigationProgress
import NavigationProgress
– 导航进度设置
在您的应用启动后调用以启用 swizzleHelper 以使导航进度正常工作setup()
NavigationProgress.setup()
– start NavigationProgress in your UIViewController
Ensure your is under , and calls in your current class.
Once your call , 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.UIViewController
UINavigationController
startNavigationProgress(with:)
viewController
startNavigationProgress()
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 progress type for only display for or NavigationProgress
oneTime
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.