• Stars
    star
    382
  • Rank 108,205 (Top 3 %)
  • Language
    Swift
  • License
    MIT License
  • Created about 8 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Stepper object that displays its value.

ValueStepper

Carthage compatible Version License Platform

Description

ValueStepper is an improved replication of Apple's UIStepper object. The problem with UIStepper is that it doesn't display the value to the user. I was tired of creating a simple UILabel just to show the value in the UI. ValueStepper integrates the value in a UILabel between the increase and decrease buttons. It's as easy as that.

Usage

To see it in action, run the example project, clone the repo, and run pod install from the Example directory first. The example project shows how to set up ValueStepper in Storyboard.

Storyboard

Drag a UIView object and set the class to ValueStepper (if needed set the module to ValueStepper too). You can now customize all the properties in IB such as the minimumValue, tintColor and so on. Make sure to set the width to 149 and the height to 29 which are the default values. Create an @IBAction on the ValueChanged control event to be notified when the value changes.

Programmatically

import ValueStepper

let valueStepper: ValueStepper = {
    let stepper = ValueStepper()
    stepper.tintColor = .whiteColor()
    stepper.minimumValue = 0
    stepper.maximumValue = 1000
    stepper.stepValue = 100
    return stepper
}()

override func viewDidLoad() {
    super.viewDidLoad()       
    valueStepper.addTarget(self, action: "valueChanged:", forControlEvents: .ValueChanged)
}

@IBAction func valueChanged1(sender: ValueStepper) {
    // Use sender.value to do whatever you want
}

Customizations

These are the available properties with the relative documentation.

/// Current value and sends UIControlEventValueChanged when modified.
@IBInspectable public var value: Double = 0.0
    
/// Minimum value that must be less than the maximum value.
@IBInspectable public var minimumValue: Double = 0.0 
    
/// Maximum value that must be greater than the minimum value.
@IBInspectable public var maximumValue: Double = 1.0
    
/// When set to true, the user can tap the label and manually enter a value.
@IBInspectable public var enableManualEditing: Bool = false
    
/// The value added/subtracted when one of the two buttons is pressed.
@IBInspectable public var stepValue: Double = 0.1
    
/// When set to true, keeping a button pressed will continuously increase/decrease the value every 0.1s.
@IBInspectable public var autorepeat: Bool = true

/// The background color of the stepper buttons while pressed.
@IBInspectable public var highlightedBackgroundColor: UIColor = UIColor(white: 1.0, alpha: 0.1)

/// The color of the +/- icons when in disabled state.
@IBInspectable public var disabledIconButtonColor: UIColor = UIColor.gray

/// The color of the +/- buttons background when in disabled state.
@IBInspectable public var disabledBackgroundButtonColor: UIColor = UIColor.clear

/// The background color of the plus and minus buttons.
@IBInspectable public var backgroundButtonColor: UIColor = UIColor.clear
    
/// The background color of the center view that contains the value label.
@IBInspectable public var backgroundLabelColor: UIColor = UIColor.clear
    
/// The text color of the value label in positioned in the center.
@IBInspectable public var labelTextColor: UIColor = UIColor.white
    
/// Describes the format of the value.
public var numberFormatter: NumberFormatter
    
// Default width of the stepper. Taken from the official UIStepper object.
public let defaultWidth = 141.0
    
// Default height of the stepper. Taken from the official UIStepper object.
public let defaultHeight = 29.0

/// Value label that displays the current value displayed at the center of the stepper.
public let valueLabel: UILabel

Installation

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

pod 'ValueStepper'

You can also use Carthage if you prefer. Add this line to your Cartfile.

github "BalestraPatrick/ValueStepper"

Requirements

iOS 8.3 and Swift 4.0 are required.

Author

I'm Patrick Balestra. Email: [email protected] Twitter: @BalestraPatrick.

License

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

Inspired by GMStepper. Thanks to Gmertk for the interesting and useful related blog post.

More Repositories

1

WhatsNew

Showcase new features after an app update similar to Pages, Numbers and Keynote.
Swift
1,506
star
2

ParticlesLoadingView

A customizable SpriteKit particles animation on the border of a view.
Swift
968
star
3

HapticButton

A button that is triggered based on the 3D Touch pressure, similar to the iOS 11 control center.
Swift
501
star
4

SquishButton

A button that squishes when pressed. As seen in the Clips app.
Swift
396
star
5

RealmVideo

An iOS app to watch Realm videos and slides at the same time on your phone.
Swift
322
star
6

Stryng

Swift strings taken to a whole new syntax level.
Swift
259
star
7

VideoToGIF

A simple Mac app to easily convert videos to GIF.
Swift
190
star
8

CleanClosureXcode

An Xcode Source Editor extension to clean the closure syntax.
Swift
185
star
9

AppleWatchCalculator

A calculator for your Apple Watch but only if you have fingers small enough to press the buttons.
Objective-C
152
star
10

OpenIt

An iOS app and a notification widget that allows the launch of other apps from the notification center.
Objective-C
111
star
11

Tweetometer

An app to see who is tweeting in your timeline.
Swift
91
star
12

ClangFormatter

Xcode Source Editor Extension for clang-format
Swift
86
star
13

HomeKitty

A Vapor 3 website to easily browse HomeKit accessories.
Swift
74
star
14

BadgesGenerator

A Swift playground to automatically generate personalized conference badges.
Swift
36
star
15

FlightUtilities

A small app that uses the private FlightUtilities.framework to show information about any flight.
Objective-C
33
star
16

appbuilders18app

The App Builders 2018 iOS and Android app built as an experiment in React Native.
JavaScript
29
star
17

SwiftBlog

A simple Swift app that reads the official Apple Swift Blog via RSS.
Swift
20
star
18

EmergencyAPI

An API written in Swift for the world emergency phone numbers.
Swift
16
star
19

iTunesConnectReports-Extension

A very simple Today View extension for iOS 8 to check if today's iTunes Connect reports are already released.
Objective-C
15
star
20

AppleWatchProductHunt

An Apple watchapp that displays the top posts from Product Hunt.
Swift
15
star
21

RxTableViewExample

A simple UITableView example implemented with RxSwift and RxDataSources.
Swift
12
star
22

Animoke

Animoji Karaoke for your iPhone X.
Swift
11
star
23

ios-links

A list of all the useful links I find, for my and your future reference.
9
star
24

TwitterKit-Rx

RxSwift extension to interact with the Twitter API via TwitterKit.
Swift
8
star
25

WWDC-2015-Scholarship

This is my WWDC 2015 student scholarship application built in SceneKit and UIKit.
Swift
8
star
26

PebbleConfigurationExample

A simple Pebble app and a website to demonstrate how to create a configuration page for your app.
7
star
27

SlacKick

A script to kick and re-add a user from all channels in a Slack group.
Swift
7
star
28

WWDC-2014-Scholarship

This is my entry for a WWDC 214 Scholarship. It's an iPad app about me!
Objective-C
7
star
29

WatchKitSettingsBundle

A demo project that shows how to use the WatchKit Settings Bundle feature.
Swift
6
star
30

SpeechRecognitionDemo

The companion project for the Tuts+ tutorial "Using the Speech Recognition API in iOS 10".
Swift
6
star
31

SiriKitDemo

The companion project for the Tuts+ tutorial "Create SiriKit Extensions in iOS 10".
Swift
6
star
32

PebbleRetreatSchedule

The perfect watch app to attend the Pebble Developer Retreat 2014.
C
5
star
33

PebblePasscodeWindow

A Passcode Window to make your Pebble watchapp safer.
C
3
star
34

NewInSwift4

The companion project for the Tuts+ tutorial "What's New in Swift 4".
Swift
3
star
35

WatchKitLayoutSystemDemo

Demo project for my tutorial written for Tuts+ about the WatchKit layout system.
Objective-C
2
star
36

WWDC-2014-Pebble-Watchface

A countdown/watchface for WWDC 2014 on your Pebble.
C
2
star
37

RandomDroplr

Just a small iPhone app developed in a few hours for fun. The app builds a random 4 characters string to generate a droplr link so every time you click next, you can see a new file.
2
star
38

PlaygroundXcode8

Contains the demo code and blog post about Playground in Xcode 8.
Swift
1
star
39

PasswordAutoFill

The companion project for the Tuts+ tutorial "Password AutoFill in iOS 11".
Swift
1
star
40

AppleSearch

A Vapor app consisting in a simple search engine built for my information retrieval course project.
Swift
1
star
41

PageControlIntroduction

A small demo on how to create an Introduction for an iOS app with a UIScrollView.
1
star
42

SpotlightEffectDemo

SpotlightEffectDemo
Objective-C
1
star
43

PebbleAppStoreHearts

A simple app to retrieve the number of hearts an app has in the Pebble App Store given its App ID. It sends a push notification when the number changes too.
1
star
44

SBBZurichHB

HackZurich 2016 project that may allow to receive Zurich SBB station loudspeaker messages on your phone.
HTML
1
star
45

RocketCorgi

A flying corgi with a rocket jetpack as our Computer Graphics final project. 🐶🚀
C++
1
star
46

lunchtime-USI

A Mac application written in Racket to browse the canteen menu for the USI university
Racket
1
star