Skip to content

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

License

Notifications You must be signed in to change notification settings

baianat/SpinningButton

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published