Giter VIP home page Giter VIP logo

gtprogressbar's Introduction

GTProgressBar

CI Status Version License Platform

GTProgressBar is a customisable progress bar. You can adjust many visual settings of the progress bar to suit your use case. Customisation can be done in both the Interface Builder and in code. Here is a preview from the example app:

Preview

Example App

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

This component is written using Swift 3 so you will need to run Xcode 8 or higher.

Usage

Many properties of GTProgressBar can be configured. Most of them can be configured in Interface Builder (@IBInspectable).

  • @IBInspectable progress: CGFloat

    This property specifies how much of the bar is filled. The allowed values are from 0.0 to 1.0 . Default is 0. If progress label is displayed the value provided in here will be displayed as % The following example will cause 50% of the bar to be filled. The label will show 50%

    progressBar.progress = 0.5
  • @IBInspectable barBorderColor: UIColor

    This property specifies the colour of the bar's border. Default is UIColor.black

    progressBar.barBorderColor = UIColor(red:0.35, green:0.80, blue:0.36, alpha:1.0)
  • @IBInspectable barBackgroundColor: UIColor

    This property specifies the background colour of the progress bar within the control. Default is UIColor.white

    progressBar.barBackgroundColor = UIColor(red:0.77, green:0.93, blue:0.78, alpha:1.0)
  • @IBInspectable barFillColor: UIColor

    This property specifies the fill colour of the progress bar. Default is UIColor.white

    progressBar.barFillColor = UIColor(red:0.35, green:0.80, blue:0.36, alpha:1.0)
  • @IBInspectable barBorderWidth: CGFloat

    This property specifies the width of the progress bar's border. Default is 2

    progressBar.barBorderWidth = 1
  • @IBInspectable barFillInset: CGFloat

    This property specifies the inset between the fill of the bar and its border. Default is 2

    progressBar.barFillInset = 1
  • @IBInspectable labelTextColor: UIColor

    This property specifies the fill colour of the label. Default is UIColor.black

    progressBar.labelTextColor = UIColor(red:0.35, green:0.80, blue:0.36, alpha:1.0)
  • @IBInspectable progressLabelInsets: UIEdgeInsets

    This property specifies the insets for the progress label. Default is UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 5)

    Currently only the left and right inset is taken into account. The label itself will stay vertically centered within the view.

    progressBar.progressLabelInsets = UIColor(red:0.35, green:0.80, blue:0.36, alpha:1.0)
  • font: UIFont

    This property allows you to specify the font for the progress label. Default is UIFont.systemFont(ofSize: 12)

    progressBar.font = UIFont.boldSystemFont(ofSize: 18)
  • barMaxHeight: CGFloat?

    This property allows you to specify the max height of the progress bar. By default the the progress bar will be sized to match the height of the whole view. If the max height is larger than the available view height it will be ignored.

    progressBar.barMaxHeight = 12

To put it altogether here is a complete example configure GTProgressBar in code:

var progressBar = GTProgressBar(frame: CGRect(x: 0, y: 0, width: 300, height: 15))
progressBar.progress = 1
progressBar.barBorderColor = UIColor(red:0.35, green:0.80, blue:0.36, alpha:1.0)
progressBar.barFillColor = UIColor(red:0.35, green:0.80, blue:0.36, alpha:1.0)
progressBar.barBackgroundColor = UIColor(red:0.77, green:0.93, blue:0.78, alpha:1.0)
progressBar.barBorderWidth = 1
progressBar.barFillInset = 2
progressBar.labelTextColor = UIColor(red:0.35, green:0.80, blue:0.36, alpha:1.0)
progressBar.progressLabelInsets = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 5)
progressBar.font = UIFont.boldSystemFont(ofSize: 18)
progressBar.barMaxHeight = 12

view.addSubview(progressBar)

Installation

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

pod "GTProgressBar"

Author

gregttn, [email protected]

License

GTProgressBar is available under the MIT license. See the LICENSE file for more info.

gtprogressbar's People

Contributors

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