Skip to content

Latest commit

 

History

History
122 lines (84 loc) · 3.7 KB

README.md

File metadata and controls

122 lines (84 loc) · 3.7 KB

SpinningButton

A custom UIButton for iOS that can be transformed into a UIActivityIndicator.

Version License Platform

Quick Start

Customization

Installation

Quick Start:

1- Drag UIButton object from the Object Library into your storyboard.

2- Set the button's class to SpinningButton in the Identity Inspector. Set its module property to SpinningButton.

3- Add import SpinningButton to the header of your view controller.

4- Have an outlet in the corresponding view controller.

@IBOutlet weak var spinningButton: SpinningButton!

5- Invoke startAnimating on SpinningButton instance according to your need to show the loader accordingly.

6- Invoke stopAnimating on SpinningButton to hide the loader and restore its original state.

Customization:

Centre:

  • You can show the spinner at the centre of the button just as follows...
    spinningButton.startAnimating(at: .centre(shrink: true))

The defualt behavoir is for the button to shrink into a circule with the spinner at the centre.

  • Alternatively, you can have the spinner at the centre, while the button retains its original size.
    spinningButton.startAnimating(at: .centre(shrink: false))

Leading:

  • You can show the spinner at the leading edge of the button just as follows...
    spinningButton.startAnimating(at: .leading())

  • Alternatively, you can customize the offset from the leading edge as well as the title displayed while the spinner is animating, just as follows...
    spinningButton.startAnimating(at: .leading(offset: 15, titleWhileLoading: "Loading"))

Trailing:

  • You can show the spinner at the trailing edge of the button just as follows...
    spinningButton.startAnimating(at: .trailing())

  • Alternatively, you can customize the offset from the trailing edge as well as the title displayed while the spinner is animating, just as follows...
    spinningButton.startAnimating(at: .trailing(offset: 15, titleWhileLoading: "Loading"))

Installation:

To install PSMeter , simply add the following line to your Podfile:

pod 'SpinningButton'

License:

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