https://github.com/ole/obslider
A UISlider subclass that adds variable scrubbing speeds (as seen in the Music app on iOS).
https://github.com/ole/obslider
Last synced: about 1 year ago
JSON representation
A UISlider subclass that adds variable scrubbing speeds (as seen in the Music app on iOS).
- Host: GitHub
- URL: https://github.com/ole/obslider
- Owner: ole
- License: mit
- Archived: true
- Created: 2011-01-03T15:45:23.000Z (over 15 years ago)
- Default Branch: main
- Last Pushed: 2024-10-22T16:35:18.000Z (over 1 year ago)
- Last Synced: 2025-03-02T15:41:05.984Z (over 1 year ago)
- Language: Objective-C
- Homepage: http://oleb.net/blog/2011/01/obslider-a-uislider-subclass-with-variable-scrubbing-speed/
- Size: 49.8 KB
- Stars: 267
- Watchers: 16
- Forks: 47
- Open Issues: 0
-
Metadata Files:
- Readme: README.mdown
- License: LICENSE.txt
Awesome Lists containing this project
README
> [!WARNING]
> This repository is no longer being maintained. I won't release new versions of the library.
# OBSlider
A `UISlider` subclass that adds variable scrubbing speeds (as seen in the iPod app on iOS) to `UISlider`.
Written by [Ole Begemann](http://oleb.net), 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 `scrubbingSpeed` is a `float` where `1.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](https://github.com/ole)
* [David Linsin](https://github.com/dlinsin): iOS 3.x compatibility
* [Sylver Bruneau](https://github.com/sylverb): iPod.app-like slider behavior (as you drag towards the slider, the thumb meets your finger at the slider)
* [Brad Sokol](https://github.com/bradsokol): Position the thumb more precisely when the user drags their finger back towards the slider
Thanks!