/IndicatorButton

🧤 Easily manage state with UIButton with UIActivityIndicatorView

Primary LanguageSwiftMIT LicenseMIT

IndicatorButton

CI Status Version License Platform

🧤Easily manage state values with UIButton with UIActivityIndicatorView (UIButtons include simple animation)

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • iOS 12+
  • Swift 5

Installation

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

pod 'IndicatorButton'

Getting Started

Storyboard Setup 🛠

add a 'UIButton' to your Storyboard and set class, module.

storyboard_setup

Code Setup 🛠

let indicatorButton = IndicatorButton(frame: , text: )

Button Animation Setup

indicatorButton.type = .shake // case normal, pulse, shake, flash

Animating start & stop

  • Basic
// Start 
indicatorButton.startAnimating()


// Stop 
indicatorButton.stopAnimating()
  • callbackable
indicatorButton.startAnimating {
  //
}
		
indicatorButton.stopAnimating {
  //
}

Button State Change

indicatorButton.isSelected = !indicatorButton.isSelected

Custommization 😎

UIButton title color

titleColor: UIColor defines the UIButton titleLabel text color. (default is .black)

UIButton title color(selected)

selectedTitleColor: UIColor (default is .white)

UIButton layer background color

bgColor: UIColor defines the UIButton layer backgroundColor. (default is .white)

UIButton layer background color(selected)

selectedBgColor: UIColor (default is .black)

UIButton layer border color

borderColor: UIColor defines the UIButton layer border color. (default is .clear)

UIButton layer border color(selected)

selectedBorderColor: UIColor(default is .clear)

UIButton layer border width

borderWidth: CGFloat defines the UIButton layer border width. (default is '1.0')

UIButton layer corner radius

cornerRadius: CGFloat defines the UIButton layer corder radius. (default is '8.0')

UIButton layer shadow

withShadow: Bool defines the UIButton shadow apply. (default is 'true')

UIButton layer shadow color

shadowColor: UIColor defines the UIButton shadow color. (default is .black)

UIActivityIndicatorView color

indicatorColor: UIColor defines the UIActivityIndicatorView color. (default is .gray)

UIActivityIndicatorView color(selected)

selectedIndicatorColor: UIColor (default is .gray)

Author

gwangyonglee, gwangyonglee92@gmail.com

License

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