GitHub - maheshsphinx/SPXLoaderButton: A lightweight and easy-to-use Swift Package that adds loading indicator support directly to UIButton. · GitHub
Skip to content

maheshsphinx/SPXLoaderButton

Folders and files

Repository files navigation

SPXLoaderButton

A lightweight UIButton subclass for iOS that displays an activity spinner while in a loading state — ideal for async actions like network calls or form submissions.


Features

  • Shows a centered UIActivityIndicatorView when loading
  • Hides title and image during loading
  • Disables interaction while loading to prevent duplicate taps
  • Customizable spinner color and style
  • Supports both code and Interface Builder (Storyboard/XIB)

Requirements

  • iOS 13.0+
  • Swift 5.9+
  • Xcode 15+

Installation

Swift Package Manager

Via Xcode

  1. Go to File → Add Package Dependencies
  2. Enter your repository URL
  3. Select the version and click Add Package

Via Package.swift

dependencies: [
    .package(url: "https://github.com/YOUR_USERNAME/SPXLoaderButton.git", from: "1.0.0")
]

Then add "SPXLoaderButton" to your target dependencies.


Usage

In Code

import SPXLoaderButton

let button = SPXLoaderButton(frame: CGRect(x: 0, y: 0, width: 200, height: 50))
button.setTitle("Submit", for: .normal)
button.backgroundColor = .systemBlue

// Start loading
button.isLoading = true

// Stop loading
button.isLoading = false

In Storyboard / XIB

  1. Add a UIButton to your view
  2. Set its class to SPXLoaderButton in the Identity Inspector
  3. Connect it as an @IBOutlet
@IBOutlet weak var submitButton: SPXLoaderButton!

submitButton.isLoading = true

Customization

button.spinnerColor = .white      // Default: .white
button.spinnerStyle = .large      // Default: .medium

License

MIT License. See LICENSE for details.

About

A lightweight and easy-to-use Swift Package that adds loading indicator support directly to UIButton.

Resources

License

Stars

Watchers

Forks

Packages

Contributors

Languages