MultiProgressView is an animatable view that depicts multiple progresses over time. The MultiProgressView
class mimics UIProgressView
as much as possible while providing additional customizations.
To run the example project, clone the repo and run the MultiProgressViewExample
target.
- iOS 9.0+
- Xcode 10.2+
- Swift 5.0+
MultiProgressView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'MultiProgressView'
MultiProgressView is also avaiable through Carthage. To install it, simply add the following line to your Cartfile:
github "mac-gallagher/MultiProgressView"
Download and drop the MultiProgressView
directory into your project.
-
Add a
MultiProgressView
to your view hierarchy:let progressView = MultiProgressView() view.addSubview(progressView)
-
Conform your class to the
MultiProgressViewDataSource
protocol and set your progress view'sdataSource
:func numberOfSections(in progressView: MultiProgressView) -> Int func progressBar(_ progressView: MultiProgressView, viewForSection section: Int) -> ProgressViewSection
progressView.dataSource = self
-
Call
setProgress(section:to:)
to update your view's progress:progressView.setProgress(section: 0, to: 0.4)
-
Drag a
UIView
onto your view controller and set the view's class toMultiProgressView
in the Identity Inspector: -
Connect your progress view to your view controller with an
IBOutlet
: -
Conform your view controller to the
MultiProgressViewDataSource
protocol and implement the required methods:func numberOfSections(in progressView: MultiProgressView) -> Int func progressBar(_ progressView: MultiProgressView, viewForSection section: Int) -> ProgressViewSection
-
Set your view controller as the progress view's
dataSource
: -
Call
setProgress(section:to:)
to update your view's progress:progressView.setProgress(section: 0, to: 0.4)
Each MultiProgressView
exposes the variables listed below. If using storyboards, many of these properties can be customized directly in the view's Attribute Inspector.
var cornerRadius: CGFloat = 0
var borderWidth: CGFloat = 0
var borderColor: UIColor? = .black
var lineCap: LineCapType = .square
var trackInset: CGFloat = 0
var trackBackgroundColor: UIColor? = .clear
var trackBorderColor: UIColor? = .black
var trackBorderWidth: CGFloat = 0
var trackImageView: UIImageView
var trackTitleLabel: UILabel
var trackTitleEdgeInsets: UIEdgeInsets = .zero
var trackTitleAlignment: AlignmentType = .center
Note: To apply a corner radius (using layer.cornerRadius
or the cornerRadius
variable) the lineCap
type must be set to .round
.
Each ProgressViewSection
exposes the following variables:
var imageView: UIImageView
var titleLabel: UILabel
var titleEdgeInsets: UIEdgeInsets = .zero
var titleAlignment: AlignmentType = .center
The setProgress(section:to:)
function be animated. For example:
UIView.animate(withDuration: 0.2) {
self.progressView.setProgress(section: 0, to: 0.4)
}
- If you found a bug, open an issue and tag as bug.
- If you have a feature request, open an issue and tag as feature.
- If you want to contribute, submit a pull request.
- In order to submit a pull request, please fork this repo and submit a pull request from your forked repo.
- Have a detailed message as to what your pull request fixes/enhances/adds.
- Swift Package Manager support
- Progress object (Foundation) support
- Storyboard/
IBInspectable
support
Mac Gallagher, [email protected].
MultiProgressView is available under the MIT License, see LICENSE for more infomation.