Git Product home page Git Product logo

multiprogressview's Introduction

MultiProgressView

Build Status CocoaPods Swift-Version CocoaPods Carthage Compatible codecov

About

MultiProgressView is an animatable view that depicts multiple progresses over time. The MultiProgressView class mimics UIProgressView as much as possible while providing additional customizations.

Example

To run the example project, clone the repo and run the MultiProgressViewExample target.

Demo1

Demo2

Requirements

  • iOS 9.0+
  • Xcode 10.2+
  • Swift 5.0+

Installation

CocoaPods

MultiProgressView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'MultiProgressView'

Carthage

MultiProgressView is also avaiable through Carthage. To install it, simply add the following line to your Cartfile:

github "mac-gallagher/MultiProgressView"

Manual

Download and drop the MultiProgressView directory into your project.

Usage

Programmatic

  1. Add a MultiProgressView to your view hierarchy:

    let progressView = MultiProgressView()
    view.addSubview(progressView)
  2. Conform your class to the MultiProgressViewDataSource protocol and set your progress view's dataSource:

    func numberOfSections(in progressView: MultiProgressView) -> Int
    func progressBar(_ progressView: MultiProgressView, viewForSection section: Int) -> ProgressViewSection
    progressView.dataSource = self
  3. Call setProgress(section:to:) to update your view's progress:

    progressView.setProgress(section: 0, to: 0.4)

Using Storyboards

  1. Drag a UIView onto your view controller and set the view's class to MultiProgressView in the Identity Inspector:

    IdentityInspector

  2. Connect your progress view to your view controller with an IBOutlet:

    IBOutlet

  3. 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
  4. Set your view controller as the progress view's dataSource:

    DataSource

  5. Call setProgress(section:to:) to update your view's progress:

    progressView.setProgress(section: 0, to: 0.4)

Customization

MultiProgressView

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.

ProgressViewSection

Each ProgressViewSection exposes the following variables:

var imageView: UIImageView
var titleLabel: UILabel
var titleEdgeInsets: UIEdgeInsets = .zero
var titleAlignment: AlignmentType = .center

Animating your progress

The setProgress(section:to:) function be animated. For example:

UIView.animate(withDuration: 0.2) {
    self.progressView.setProgress(section: 0, to: 0.4)
}

Contributing

  • 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.

To-do

  • Swift Package Manager support
  • Progress object (Foundation) support
  • Storyboard/IBInspectable support

Author

Mac Gallagher, [email protected].

License

MultiProgressView is available under the MIT License, see LICENSE for more infomation.

multiprogressview's People

Contributors

mac-gallagher avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.