Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thePsguy/ButtonProgressBar-iOS
A small and flexible (well documented) UIButton subclass with animated loading progress, and completion animation.
https://github.com/thePsguy/ButtonProgressBar-iOS
animated download loading progress subclass uibutton
Last synced: 6 days ago
JSON representation
A small and flexible (well documented) UIButton subclass with animated loading progress, and completion animation.
- Host: GitHub
- URL: https://github.com/thePsguy/ButtonProgressBar-iOS
- Owner: thePsguy
- License: mit
- Created: 2017-04-12T18:36:52.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-08-25T05:20:41.000Z (over 3 years ago)
- Last Synced: 2024-04-24T14:48:58.128Z (8 months ago)
- Topics: animated, download, loading, progress, subclass, uibutton
- Language: Swift
- Homepage: https://cocoapods.org/pods/ButtonProgressBar-iOS
- Size: 1.24 MB
- Stars: 574
- Watchers: 14
- Forks: 48
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - ButtonProgressBar-iOS - A small and flexible UIButton subclass with animated loading progress, and completion animation. (UI / Button)
- awesome-ios-star - ButtonProgressBar-iOS - A small and flexible UIButton subclass with animated loading progress, and completion animation. (UI / Button)
- awesome-ios - ButtonProgressBar-iOS - A small and flexible (well documented) UIButton subclass with animated loading progress, and completion animation. [•](https://raw.githubusercontent.com/thePsguy/ButtonProgressBar-iOS/master/output_F2Ryon.gif) (Content / Button)
README
# ButtonProgressBar-iOS
[![Version](https://img.shields.io/cocoapods/v/ButtonProgressBar-iOS.svg?style=flat)](http://cocoapods.org/pods/ButtonProgressBar-iOS)
[![License](https://img.shields.io/cocoapods/l/ButtonProgressBar-iOS.svg?style=flat)](http://cocoapods.org/pods/ButtonProgressBar-iOS)
[![Platform](https://img.shields.io/cocoapods/p/ButtonProgressBar-iOS.svg?style=flat)](http://cocoapods.org/pods/ButtonProgressBar-iOS)
[![Contact](https://img.shields.io/badge/contact-%40thePsguy-3a8fc1.svg)](https://twitter.com/thePsguy)## Example
* For LIVE PREVIEW on Appetize in your browser itself, [click here](https://appetize.io/app/rcb15cyg78agt90pqa3xujx3cc).
* To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Requirements
iOS > 7.0## Installation
ButtonProgressBar-iOS is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod 'ButtonProgressBar-iOS'
```## Usage
```Swift
import ButtonProgressBar_iOS
```
#### Initialize just like you would any other UIButton:
```swift
var progressButton = ButtonProgressBar(frame: CGRect)
view.addSubview(progressButton)
```
#### Since this is a UIButton subclass, targets and labels can be set in the same way:
```swift
progressButton.addTarget(nil, action: #selector(self.tapped), for: .touchUpInside)
progressButton.setTitle("Download", for: .normal)
```
#### The completion image can be set with;
_This image must be set since no default exists._
```swift
setCompletionImage(image: UIImage)
```
#### Indeterminate loading can be handled with the following functions:
```swift
startIndeterminate(withTimePeriod time: TimeInterval)
startIndeterminate(withTimePeriod time: TimeInterval, andTimePadding padding: TimeInterval)/*
Time Padding is the duration (default 0.5), in seconds, before starting the next cycle.
Time Period is the total time (animation + padding) that 1 cycle of the loading takes.
*/stopIndeterminate() //Stops the indeterminate loading.
```
#### For determinate usage or otherwise, progress can be set with:
```swift
setProgress(progress: CGFloat, _ animated: Bool)
/*
Progress ranges from 0.0 to 1.0If animated is true, linearly animates to progress.
*/resetProgress() //Set progress to 0.0 unanimated.
```
#### Set the progress and background colors:
```swift
setBackgroundColor(color: UIColor)
setProgressColor(color: UIColor)
```
#### To explicitly show/hide the title / image:
```swift
hideTitle(_ hidden: Bool)
hideImage(_ hidden: Bool)
```
#### Stop indeterminate loading if active, set progress to 1.0 animated, and display completion image if set.
Needs to be called explicitly when loading determinate as well.
```swift
triggerCompletion()
```
## Author
Pushkar Sharma, [email protected]
Inspiration from [Dribbble](https://dribbble.com/shots/2551579-Download-Button)
[Android version](https://github.com/ishaan1995/ButtonProgressBar) available!
## License
ButtonProgressBar-iOS is available under the MIT license. See the LICENSE file for more info.