Skip to content

Latest commit

 

History

History
60 lines (46 loc) · 2.23 KB

File metadata and controls

60 lines (46 loc) · 2.23 KB

ExtButtonProgress

Version Platform Language License

This simple extension adds progress indicator to rounded UIButton.

Usage

Just add file ExtButtonProgress.swift in your project. Use method showProgressIndicator( width:color:backgroundColor:cycleDuration:) to begin show progress indicator and method hideProgressIndicator() to hide indicator.

Important! Button must be rounded for using this extension.

Code example

class ViewController: UIViewController {
    
    // Our rounded button
    @IBOutlet weak var roundedButton: UIButton!
    
    // Push 'Start' button
    @IBAction func pushStart(_ sender: UIButton) {
        // Show progress indicator for our buttnon 
        roundedButton.showProgressIndicator(width: 5, color: UIColor.purple, backgroundColor: UIColor.lightGray, cycleDuration: 7.0)
    }
    
    // Push 'Stop' button
    @IBAction func pushStop(_ sender: UIButton) {
        // Hide progress indicator
        roundedButton.hideProgressIndicator()
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
  
        // Make rounded button
        roundedButton.layer.cornerRadius = 0.5 * buttonWithProgressbar.bounds.size.width
        roundedButton.clipsToBounds = true
    }
}

Installation

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

pod "ExtButtonProgress", :git => 'https://github.com/AlexSmet/ExtButtonProgress.git'

Author

Created by Alexander Smetannikov (alexsmetdev@gmail.com) Thanks to Evgeny Safronov

License

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