Simple way to display activity indicator inside the button.

Overview

QBIndicatorButton

Build Status Version License Platform

Custom of UIButton in Swift.

Screenshot

Example

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

Features

  • Edit button style from storyboard or code
  • Set a gradient background and gradient directions
  • Customize the corner radius, border color, border width
  • Customize the button animation: scale, scale duration
  • Edit the button shadows: color, opacity, offset, radius
  • Show, hide activity indicator inside the button

Requirements

  • Swift 5.0
  • iOS 11.0+

Getting started

Storyboard Setup

Drag and drop UIButton into your Storyboard and set its class and module to QBIndicatorButton.

custom class

Customize your button by setting properties from the Interface Builder.

custom properties

Code Setup

var loadingButton: QBIndicatorButton!
loadingButton = QBIndicatorButton(text: "Tap me",
                              textColor: UIColor.white,
                              font: UIFont.systemFont(ofSize: 18, weight: .semibold),
                              backgroundColor: .systemBlue,
                              cornerRadius: 4.0)

Button touch closure.

loadingButton.touch({ btn in
    // do stuff here
    btn.start()
}, for: .touchUpInside)

Show loading indicator.

loadingButton.start()
// or
loadingButton.start {
    // do something when start
    print("starting...")
}

Hide loading indicator.

loadingButton.stop()
// or
loadingButton.stop {
    // do something when stop
    print("stopping...")
}

Appearance

Supported appearance properties are:

Property Type Description Default value
animatedScale CGFloat Animated scale 1.0
animatedScaleDuration Double Animated scale duration 0.2
borderColor UIColor Border color UIColor.clear
borderWidth CGFloat Border width 0.0
cornerRadius CGFloat Corner radius 4.0
shadowColor UIColor The color of the layer's shadow UIColor.clear
shadowOffset CGSize The offset of the layer's shadow .zero
shadowOpacity Float The opacity of the layer's shadow 0.0
shadowRadius CGFloat The blur radius of the layer's shadow 0.0
gradientEnabled Bool Enable gradient background color false
gradientStartColor UIColor Start of color gradient UIColor.clear
gradientEndColor UIColor End of color gradient UIColor.clear
gradientDirection Int Direction of color gradient 0~7 1
activityIndicatorPosition Int Position of activity indicator 0~2 1
titleFadeDuration Double Button title fade animated duration 0.3
indicatorRotateDuration (v0.1.7) CFTimeInterval The activity indicator rotate duration 1.0
indicatorStrokeColor (v0.1.7) UIColor Custom color of activity indicator .white
indicatorStrokeWidth (v0.1.7) CGFloat Stroke width of activity indicator 3.0

QBIndicatorButton also supported round every single corner of the button.

// round topLeft and topRight corner only
loadingButton.roundCorners(corners: [.topLeft, .topRight], radius: 20)
// or
// round all corner
loadingButton.roundCorners(corners: [.allCorners], radius: 20)

Predefined positions of activity indicator.

public enum IndicatorPosition: Int {
    case left   = 0
    case center = 1
    case right  = 2
}

Predefined directions for color gradient.

public enum GradientDirection: Int {
    case toTop         = 0
    case toRight       = 1
    case toBottom      = 2
    case toLeft        = 3
    case toTopRight    = 4
    case toTopLeft     = 5
    case toBottomRight = 6
    case toBottomLeft  = 7
}

Installation

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

pod 'QBIndicatorButton'

Contributing

  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you need help, open an issue.
  • If you want to contribute, submit a pull request.

MIT License

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

Made with ❤️ by sjc-bui.

You might also like...
Whisper is a component that will make the task of display messages and in-app notifications simple. It has three different views inside
Whisper is a component that will make the task of display messages and in-app notifications simple. It has three different views inside

Description 🍃 Break the silence of your UI, whispering, shouting or whistling at it. Whisper is a component that will make the task of displaying mes

📱💬🚦 TinyConsole is a micro-console that can help you log and display information inside an iOS application, where having a connection to a development computer is not possible.
📱💬🚦 TinyConsole is a micro-console that can help you log and display information inside an iOS application, where having a connection to a development computer is not possible.

TinyConsole TinyConsole is a tiny log console to display information while using your iOS app and written in Swift. Usage Wrap your Main ViewControlle

How to Display Video from URL inside custom design UIView

Technicalisto How to Display Video from URL inside custom design UIView Add your UIView and connect it . Add This method for display func DisplayVideo

TTGSnackbar shows simple message and action button on the bottom or top of the screen with multi kinds of animation, which is written in Swift3 and inspired by Snackbar in Android. It also support showing custom view, icon image or multi action button. Customizable download button with progress and transition animations. It is based on Apple's App Store download button.
Customizable download button with progress and transition animations. It is based on Apple's App Store download button.

AHDownloadButton is a customizable download button similar to the download button in the latest version of Apple's App Store app (since iOS 11). It fe

Revamped Download Button. It's kinda a reverse engineering of Netflix's app download button.
Revamped Download Button. It's kinda a reverse engineering of Netflix's app download button.

NFDownloadButton Revamped Download Button Requirements Installation Usage License Requirements iOS 8.0+ Swift 4.2+ Xcode 10.0+ Installation CocoaPods

Custom UIView class that hosts an array of UIbuttons that have an 'underline' UIView beneath them which moves from button to button when the user presses on them.
Custom UIView class that hosts an array of UIbuttons that have an 'underline' UIView beneath them which moves from button to button when the user presses on them.

Swift-Underlined-Button-Bar Custom UIView class that hosts an array of UIbuttons that have an 'underline' UIView beneath them which moves from button

MUDownloadButton -  a Progressive Download button written in pure swift and inspired by AppStore download button
MUDownloadButton - a Progressive Download button written in pure swift and inspired by AppStore download button

MUDownloadButton is a Progressive Download button written in pure swift and inspired by AppStore download button . feel free to contribute and pull requests

Hamburger Menu Button -  A hamburger menu button with full customization
Hamburger Menu Button - A hamburger menu button with full customization

Hamburger Menu Button A hamburger menu button with full customization. Inspired by VinhLe's idea on the Dribble How to use it You can config the looks

Bar Button Item that can be moved anywhere in the screen, like Android's stickers button.
Bar Button Item that can be moved anywhere in the screen, like Android's stickers button.

FlowBarButtonItem Bar Button Item that can be moved anywhere in the screen, like Android's stickers button. [![CI Status](http://img.shields.io/travis

An easy way to add a shimmering effect to any view with just one line of code. It is useful as an unobtrusive loading indicator.
An easy way to add a shimmering effect to any view with just one line of code. It is useful as an unobtrusive loading indicator.

LoadingShimmer An easy way to add a shimmering effect to any view with just single line of code. It is useful as an unobtrusive loading indicator. Thi

An easy way to add a shimmering effect to any view with just one line of code. It is useful as an unobtrusive loading indicator.
An easy way to add a shimmering effect to any view with just one line of code. It is useful as an unobtrusive loading indicator.

LoadingShimmer An easy way to add a shimmering effect to any view with just single line of code. It is useful as an unobtrusive loading indicator. Thi

Shopify’s Mobile Buy SDK makes it simple to sell physical products inside your mobile app.
Shopify’s Mobile Buy SDK makes it simple to sell physical products inside your mobile app.

Shopify’s Mobile Buy SDK makes it simple to sell physical products inside your mobile app. With a few lines of code, you can connect your app with the Shopify platform and let your users buy your products using Apple Pay or their credit card.

Video mp4 record save display - How to Take , Save and Display a .mp4 Video

Technicalisto How to Take , Save and Display a .mp4 Video Add your design with v

🖥 Control your display's brightness & volume on your Mac as if it was a native Apple Display
🖥 Control your display's brightness & volume on your Mac as if it was a native Apple Display

🖥 Control your display's brightness & volume on your Mac as if it was a native Apple Display. Use Apple Keyboard keys or custom shortcuts. Shows the native macOS OSDs.

Simple network activity logger for iOS
Simple network activity logger for iOS

Reqres is a simple library for logging all requests and responses in your app. It supports Alamofire and also requests made via native NSURLSession. ⬆

A Swift micro-framework to easily deal with weak references to self inside closures

WeakableSelf Context Closures are one of Swift must-have features, and Swift developers are aware of how tricky they can be when they capture the refe

A set of tools to trim, crop and select frames inside a video

PryntTrimmerView A set of tools written in swift to crop and trim videos. Example To run the example project, clone the repo, and run pod install from

Releases(0.1.7)
Owner
Quan Bui Van
do the simple thing first.
Quan Bui Van
UIGradient - A simple and powerful library for using gradient layer, image, color

UIGradient is now available on CocoaPods. Simply add the following to your project Podfile, and you'll be good to go.

Đinh Quang Hiếu 247 Dec 1, 2022
A simple UIColor category to get color with hex code.

TFTColor A simple UIColor library to get UIColor object from RGB hex string/value, CMYK hex string/value or CMYK base component values. You can also r

Burhanuddin Sunelwala 18 Jun 21, 2022
The easiest way to handle a simple full screen activity indicator in iOS. Written in Swift.

LLSpinner An easy way to handle full screen activity indicator. Easy to use Get Started // Show spinner LLSpinner.spin() // Hide spinner LLSpinner.st

Aleph Retamal 36 Dec 9, 2021
A simple and awesome loading Activity Indicator(with block moving animation) for your iOS app.

BPBlockActivityIndicator BPBlockActivityIndicator is a clean and easy-to-use Activity Indicator meant to display the progress of an ongoing task on iO

Ben.Park 43 Nov 6, 2021
A simple and customizable activity indicator.

日本語 KRActivityIndicatorView KRActivityIndicatorView is a simple and customizable activity indicator written in Swift. You can add KRActivityIndicatorV

K.R.Impedance 47 Jul 11, 2022
Automatically sets the network activity indicator for any performed request.

BigBrother BIG BROTHER IS WATCHING YOU. BigBrother is a Swift library made for iOS that automatically watches for any performed request and sets the n

Marcelo Fabri 446 Dec 17, 2022
A beautiful activity indicator and modal alert written in Swift (originally developed for my app DoodleDoodle) Using blur effects, translucency, flat and bold design - all iOS 8 latest and greatest

SwiftSpinner SwiftSpinner is an extra beautiful activity indicator with plain and bold style. It uses dynamic blur and translucency to overlay the cur

Marin Todorov 2.1k Dec 19, 2022
A lightweight and awesome loading Activity Indicator for your iOS app.

BPCircleActivityIndicator BPCircleActivityIndicator is a clean and easy-to-use Activity Indicator meant to display the progress of an ongoing task on

Ben.Park 46 Aug 12, 2022
Floating indicator, mimicrate to indicator which appear when silent mode turn on / off. Support large texts.

SPIndicator About Mimicrate to indicator which appear when silent mode turn on / off. Availalbe 2 animated presets: done & error. Also support custom

Ivan Vorobei 568 Dec 30, 2022
Recording Indicator Utility lets you turn off the orange microphone recording indicator light for live events and screencasts.

Recording Indicator Utility Recording Indicator Utility lets you turn off the orange microphone recording indicator light, making it ideal for profess

Tyshawn Cormier 121 Jan 1, 2023