iOS Swift button that animates while an action is being processed.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
ProcessButton.xcodeproj
ProcessButton
ProcessButtonTests
.gitignore
LICENSE
ProcessButton.gif
ProcessButton.podspec
README.md

README.md

ProcessButton

iOS Buttons that animate while an action is being processed. Written in Swift.

This library was extracted from an iOS application that I was working on at the time. It's used for any sort of action that is processed asynchronously, and shows a loading-like animation until the action is done.

Usage

Basic asynchronous task animation

@IBOutlet weak var btnSignIn: ProcessButton!

btnSignIn.animate(true)

// Do some some asynchronous stuff here
// and display result from callback

if callbackSuccess {
  self.btnSignIn.showSuccessText("Success", seconds: ProcessButtonUtil.Length.Short)
} else {
  self.btnSignIn.showErrorText("Error", seconds: ProcessButtonUtil.Length.Long)
}

Optional To change the colors of the lines and the duration, put this in your AppDelegate didFinishLaunchingWithOptions

// App wide customization
let colors = [UIColor.blueColor(), UIColor.redColor(), UIColor.greenColor()]
let duration: NSTimeInterval = 0.3
    
ProcessButtonUtil.sharedInstance
  .setColors(colors) // The colors for the animating lines. Can be any number of colors
  .setDuration(duration) // The time for each line to animate. Default is 0.5

Take a look at the project to see a full example.

Requirements

  • iOS 8 or later
  • Xcode 6 or later

Author

Vidar Ottosson, viddi@nplexity.com

License

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