ProgressButton - Custom button class that displays a progress bar around it to gauge

Overview

ProgressButton Carthage compatible GitHub release

Gif video

Check it out

To run the example project, clone the repo, and open the 'Example/Example.xcodeproj' file.

Requirements

This component is written using Swift and Dynamic Frameworks, so iOS 8.x is required. However you may want to manually import the source files into your project, if you need to support 7.x.

Installation

ProgressButton is available through Carthage. To install it, simply add the following line to your Cartfile:

1.1.1">
github "sprint84/ProgressButton" ~> 1.1.1

###Installing Carthage

To install the carthage tool on your system, please download and run the Carthage.pkg file for the latest release, then follow the on-screen instructions.

Alternately, you can use Homebrew and install the carthage tool on your system simply by running brew update and brew install carthage.

For further details, please visit the Carthage Github page

##Usage

ProgressButton is intended to be used in conjunction with UIToolbar or UITabBar. By default, when instantiated this component will try to center itself within its parent view. Although possible, setting the frame of this button manually is not recommended. Using the button in a UIToolbar is quite simple. First you need to import the module:

import ProgressButton

Then instantiate the view and add it to a UIToolbar or UITabBar.

let addButton = ProgressButton()
addButton.addInView(toolbar)

You can normally add actions to ProgressButton using addTarget:action:forControlEvents since it is a subclass of UIButton. However, we added a simpler closure method if you want to keep code inline.

addButton.setAction {
    print("Action performed")
}

ProgressButton displays a progress bar around it's frame. Setting the current progress works as expected:

addButton.setProgress(self.progress, animated: true)

Customization

ProgressButton supports some layout customizations, and we are working to improve customizable parameters in the future. For example, ProgressButton supports 3 color levels, that can be triggered by a threshold value.

public var normalProgressColor: UIColor
public var advisoryProgressColor: UIColor
public var warningProgressColor: UIColor 

Users can define when those colors will be triggered, in a range 0..1. If you set values above 1.0 for these threshold values, the progress bar will always display the normalProgressColor:

public var advisoryProgressThreshold: Double
public var warningProgressThreshold: Double

You can also change the position where the progress arc starts. The default value for the initial angle is 90° or π/2. That means the arc will begin drawing from the bottom of the circunference.

And you can change an offset angle that will be calculated from the initial angle in both directions (clockwise and counter-clockwise), creating an empty section on the initial angle position. These values must be set in Radians.

/// Starting point, in radian angles, where the progress arc will begin. Default: π/2
public var initialAngle: Double

/// Arc offset, in radian angles, from `initialAngle` where the progress arc will start drawing. Default: π/6
public var arcOffset: Double

Angle description

Author

Reefactor, Inc., [email protected]

License

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

You might also like...
Lickable-Button We made the buttons on the screen look so good you'll want to lick them

Lickable-Button We made the buttons on the screen look so good you'll want to lick them. - Steve Jobs A little SwiftUI button project at WWDC 2021 Lic

Craft that perfect SwiftUI button effect 👌🏼
Craft that perfect SwiftUI button effect 👌🏼

buttoncraft (SwiftUI 3.0 App) Experimenting with SwiftUI 3.0 whilst creating a practical app to craft that perfect button style. ✈️ Testflight https:/

iOS Pod for a Soft UI (Neumorphic) Button for UIKit written in Swift
iOS Pod for a Soft UI (Neumorphic) Button for UIKit written in Swift

iOS Pod for a Soft UI (Neumorphic) Button for UIKit written in Swift

An open-source library to use with SwiftUI, It allows you to create Floating menu action button.
An open-source library to use with SwiftUI, It allows you to create Floating menu action button.

Floating Menu Action Button Example Overview This is an open-source library to use with SwiftUI. It allows you to create Floating menu action button. Ins

iOS 7-style bouncy button.

SSBouncyButton SSBouncyButton is simple button UI component with iOS 7-style bouncy animation. Take A Look Try It! pod 'SSBouncyButton', '~ 1.0' Use

Flat button with 9 different states using POP
Flat button with 9 different states using POP

VBFPopFlatButton Flat button with 21 different states and 2 types animated using pop. These are some examples of both types in different states: And h

Flat design pressable button for iOS developers.
Flat design pressable button for iOS developers.

HTPressableButton HTPressableButton is designed for iOS developers to be able to spend time developing ideas, not building basic buttons. These stylis

Material Design Floating Action Button in liquid state
Material Design Floating Action Button in liquid state

LiquidFloatingActionButton [] (https://github.com/Carthage/Carthage) LiquidFloatingActionButton is floating action button component of material design

Simple and customizable button in Swift
Simple and customizable button in Swift

SwiftyButton Maintainer(s): @nickm01 @pmacro @aryamansharda Simple and customizable button in Swift. Installation Cocoapods pod 'SwiftyButton' Cartha

Owner
Guilherme Moura
Guilherme Moura
Custom loading button with progress swiftui

CustomLoadingButton Simple Custom Loading Progress Button for SwiftUI Version 1.0.0 This version requires Xcode 11+ SwiftUI iOS 13+ macOS 10.15+ Insta

Tariqul 1 Dec 14, 2022
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

Leonardo Cardoso 433 Nov 15, 2022
Full-featured IBDesignable UIButton class

SpicyButton Full-featured IBDesignable UIButton class Installation Add the following to your project's Podfile: pod 'SpicyButton' Usage You can easily

Luke Crum 2 Sep 6, 2022
Cute Animated Button written in Swift.

DOFavoriteButton Cute Animated Button written in Swift. It could be just right for favorite buttons! Requirements iOS 7.0+ Swift 1.2 Installation Cart

Daiki Okumura 3.6k Dec 29, 2022
Customizable and easy to use expandable button in Swift.

ExpandableButton Requirements iOS 9.0+ Installation CocoaPods: Add the following line to your Podfile: pod 'ExpandableButton' #for swift less than 4.

Dmytro Mishchenko 98 Dec 5, 2022
Easily customizable floating button menu created with SwiftUI

FloatingButton Easily customizable floating button menu created with SwiftUI We are a development agency building phenomenal apps. Usage Create main b

Exyte 715 Dec 30, 2022
Floaty is simple floating action button for iOS.

Floaty is simple floating action button for iOS. (formerly KCFloatingActionButton) Why change the name? Follow the swift naming convention. KCF

Lee Sun-Hyoup 1.5k Jan 7, 2023
IGStoryButtonKit provides an easy-to-use button with rich animation and multiple way inspired by instagram story/stories.

Introduction Have you ever seen UI like instagram story, haven't you? Actually, features like instagram story have been implemented in many applicatio

mutation 34 Nov 8, 2022
LTHRadioButton - A radio button with a pretty animation

LTHRadioButton Slightly inspired by Google's material radio button. The clip below has 3 sections: full speed, 25% and 10%, but after converting it to

Roland Leth 368 Dec 16, 2022
Multiple state tap-to-toggle UIButton (like old camera flash button)

Multiple State Toggle UIButton A UIButton subclass that implements tap-to-toggle button text. (Like the camera flash and timer buttons) Usage Just cre

Yonat Sharon 83 Oct 11, 2022