• Stars
    star
    267
  • Rank 153,621 (Top 4 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created almost 14 years ago
  • Updated 6 months ago

Reviews

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

Repository Details

A UISlider subclass that adds variable scrubbing speeds (as seen in the Music app on iOS).

OBSlider

A UISlider subclass that adds variable scrubbing speeds (as seen in the iPod app on iOS) to UISlider.

Written by Ole Begemann, January 2011.

Usage

Copy OBSlider.h and OBSlider.m to your project and instantiate an OBSlider wherever you would use a UISlider. If you create the slider in Interface Builder, set its class to OBSlider on the Identity tab.

The slider works with variable scrubbing speeds out of the box. In the action method you have assigned to UIControlEventValueChanged, you can access the scrubbingSpeed variable to get the current scrubbing speed. Scrubbing scrubbingSpeedis afloatwhere1.0f` is the normal scrubbing speed.

To modify which scrubbing speed should be set at which vertical offset position of the user's touch, you can modify the scrubbingSpeeds and scrubbingSpeedChangePositions arrays. Both arrays should contain the same number of objects. scrubbingSpeedChangePositions should indicate the vertical offsets at which scrubbing speed changes should take place in ascending order. The first entry in this array should always be [NSNumber numberWithFloat:0.0f]. scrubbingSpeeds should contain the actual values for the scrubbing speed that correspond to the offset positions.

The default values for the two arrays are:

scrubbingSpeeds = [NSArray arrayWithObjects:
 [NSNumber numberWithFloat:1.0f],
 [NSNumber numberWithFloat:0.5f],
 [NSNumber numberWithFloat:0.25f],
 [NSNumber numberWithFloat:0.1f],
 nil];

scrubbingSpeedChangePositions = [NSArray arrayWithObjects:
 [NSNumber numberWithFloat:0.0f],
 [NSNumber numberWithFloat:50.0f],
 [NSNumber numberWithFloat:100.0f],
 [NSNumber numberWithFloat:150.0f],
 nil];

(That is, scrubbing speed changes from 100% to 50% to 25% to 10% when the user moves the finger upward/downward by 50.0/100.0/150.0 points, respectively.)

Requirements

OBSlider 1.0.0 (tagged with 1.0.0) works in iOS 3.0+.

With version 1.1.0 (tagged 1.1.0) I converted the source code to Automatic Reference Counting (ARC) and raised the deployment target of the demo app to iOS 5.0. If you want to support earlier iOS versions, please check out the 1.0.0 tag.

Demo

Open the demo project OBSliderDemo.xcodeproj in Xcode and run it on an iPhone or the iPhone Simulator. Drag the slider around and, while dragging, move your finger upwards/downwards to adjust the scrubbing speed.

Untested

The class is basically untested. Please report bugs via the issue tracker on GitHub.

License

Licensed under the MIT license. You can use the code in your commercial and non-commercial projects.

Contributors

  • Ole Begemann
  • David Linsin: iOS 3.x compatibility
  • Sylver Bruneau: iPod.app-like slider behavior (as you drag towards the slider, the thumb meets your finger at the slider)
  • Brad Sokol: Position the thumb more precisely when the user drags their finger back towards the slider

Thanks!

More Repositories

1

whats-new-in-swift-4

An Xcode playground showcasing the new features in Swift 4.0.
Swift
1,827
star
2

OBShapedButton

A UIButton subclass that works with for non-rectangular button shapes.
Objective-C
946
star
3

whats-new-in-swift-4-2

An Xcode playground demonstrating the new features in in Swift 4.2.
Swift
872
star
4

OLEContainerScrollView

A UIScrollView subclass that intelligently handles multiple child scroll views and does not interfere with UIKitʼs cell reuse functionality.
Objective-C
588
star
5

Animated-Paths

Demo project: Animating the drawing of a CGPath with CAShapeLayer.strokeEnd
Objective-C
505
star
6

swiftui-view-lifecycle

Observe how different SwiftUI container views affect state and lifecycle events (onAppear, onDisappear).
Swift
374
star
7

CollectionViewParallaxScrolling

A custom UICollectionViewFlowLayout to support parallax scrolling in cells. Check out the accompanying blog post for more info.
Objective-C
250
star
8

Ampere

Adding multiplication and division to the units of measurement types in Foundation.
Swift
171
star
9

swiftui-layout-inspector

A tool for learning how the SwiftUI layout system works, and for debugging your own layout code.
Swift
168
star
10

SortedArray

An array that keeps its elements sorted according to a given sort predicate.
Swift
165
star
11

CustomScrollView

A very simple implementation of a scroll view on iOS. Not meant for production, just for learning purposes. Please check out the accompanying blog post.
Objective-C
154
star
12

OBGradientView

A simple UIView wrapper for CAGradientLayer. For the times when it's more convenient to use a view instead of a CALayer.
Objective-C
112
star
13

NSBundle-OBCodeSigningInfo

Check an app bundle's code signing and sandboxing state to NSBundle.
Objective-C
106
star
14

swift-rp-pico-bare

Embedded Swift on the Raspberry Pi Pico without the Pico C/C++ SDK
C
93
star
15

Storyboard-Strings-Extraction

Automatically extract translatable strings from Xcode storyboards and update .strings files.
Shell
74
star
16

SilentPush

An iOS test app for testing silent push notifications and background fetching.
Swift
71
star
17

CGPathHitTesting

A demo iOS app to illustrate hit testing with CGPathCreateCopyByStrokingPath()
Objective-C
71
star
18

pico-embedded-swift

Embedded Swift on the Raspberry Pi Pico
CMake
62
star
19

AppointmentList

Sample iOS app that lists events from the device's calendar store in a table view and groups them by date.
Objective-C
48
star
20

RemoteViewControllers

Introspection of the private and undocumented remote view controllers feature in iOS 6
Objective-C
45
star
21

iphone-6-plus-rendering

Quick and dirty test apps to understand how the built-in downsampling to screen resolution works on the iPhone 6 Plus.
Swift
44
star
22

GestureRecognition

Sample iOS app for a blog post about gesture recognition and attention to detail
Objective-C
42
star
23

itunesconnect-financialreports

Converts Financial Reports from iTunes Connect (App Store) to HTML
Ruby
37
star
24

OSLogStoreTest

Test app for evaluating if apps can access their own OSLog logs via OSLogStore.
Swift
30
star
25

AnalogDial

A circular analog dial that can display a numeric value in a specified range (like an analog speedometer).
Swift
24
star
26

AppleCoreDataModels

21
star
27

NotificationUnregistering

Testing the behavior of the block based NotificationCenter API. Do you have to call NotificationCenter.removeObserver(_:) or is it enough to let the observer token go out of scope? Turns out: the former (tested on iOS 11.2).
Swift
16
star
28

ConcurrencyBenchmark

Swift
15
star
29

HexHexHex

A parser for the Intel Hexadecimal Object File Format (.hex), written in Swift.
Swift
14
star
30

Kaffeekasse

Sample apps for a Passbook tutorial on my blog.
C++
14
star
31

transcribe

A Swift parser for output files from automated transcription services. An experiment inspired by the Swift Community Podcast.
Swift
13
star
32

Picobello

An assembler for the Microchip PIC instruction set, written in Swift.
Swift
13
star
33

topaz

An attempt to reimplement a minimal version of the Swift standard library. Just for fun — I doubt this has practical applications.
Swift
12
star
34

RGBtoCMYK

A simple command-line Cocoa app to convert images to CMYK
Objective-C
10
star
35

SwiftUI-Mac-Focus

Test project for playing with focus, keyboard shortcuts, menu commands in SwiftUI on the Mac
Swift
10
star
36

CAShapeLayer-Animation

Demo project for a Stack Overflow question: "Animate CAShapeLayer path on animated bounds change"
Objective-C
9
star
37

Funtime

A Swift interface for the Objective-C Runtime API
Swift
8
star
38

CollectionViewContentSizeAnimation

Demo project for a Stack Overflow question.
Objective-C
8
star
39

SwiftPM-embedded-minimal

Swift
6
star
40

OBStack

OBStack is a very simple implementation of a stack data structure (last in, first out) in Cocoa.
Objective-C
5
star
41

AsyncSequenceOperators

Experimental reimplementations of functional reactive operators for AsyncSequence. DO NOT USE IN PRODUCTION!
Swift
5
star
42

AsyncXMLParsing

An AsyncSequence wrapper for Foundation’s XMLParser (experimental)
Swift
4
star
43

SwiftUIAnimationBug

https://twitter.com/olebegemann/status/1587912494290444290
Swift
3
star
44

twitter-backup

A Ruby script to backup tweets (in the raw JSON format)
Ruby
3
star
45

rust-rp-pico-template

A cargo-generate template for embedded Rust development on the Raspberry Pi Pico.
Rust
2
star
46

docopt.objc

Incomplete beginnings of an implementation of the docopt language in Objective-C.
Objective-C
2
star
47

CoreDataDebugging

Swift
2
star
48

SetSolver

A solver for the card game Set.
Swift
1
star
49

SwiftConcurrencyDeadlock

Swift
1
star