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.
- Shows a centered
UIActivityIndicatorViewwhen 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)
- iOS 13.0+
- Swift 5.9+
- Xcode 15+
- Go to File → Add Package Dependencies
- Enter your repository URL
- Select the version and click Add Package
dependencies: [
.package(url: "https://github.com/YOUR_USERNAME/SPXLoaderButton.git", from: "1.0.0")
]Then add "SPXLoaderButton" to your target dependencies.
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- Add a
UIButtonto your view - Set its class to
SPXLoaderButtonin the Identity Inspector - Connect it as an
@IBOutlet
@IBOutlet weak var submitButton: SPXLoaderButton!
submitButton.isLoading = truebutton.spinnerColor = .white // Default: .white
button.spinnerStyle = .large // Default: .mediumMIT License. See LICENSE for details.
