Skip to content

A UISlider subclass which adjusts its appearance based on the positional attitude of an iOS device.

License

Notifications You must be signed in to change notification settings

TeehanLax/TLTiltSlider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TLTiltSlider

TLTiltSlider is a UISlider subclass with an angular gradient for a Thumb image which adjusts its appearance based on the positional attitude of the device. The movement of the gradient when re-orientating the device is subtle. This mimics the iOS 6 Music app (notice the gradient on the sliders).

This class demonstrates how to use the Core Motion framework to adjust to device attitude changes. Rendering angular gradients is complex and it may affect your application's responsiveness on older devices. Always make sure to test your application on an actual device.

One angular gradient Another angular gradient

How to Use

Drag TLTiltSlider.h and TLTiltSlider.m, as well as the images in the Resources directory, into your project. Make sure to link against the Core Motion framework.

Alternatively, you can use CocoaPods:

pod search TLTiltSlider

Create an instance of TLTiltSlider and add it to a view hierarchy. The UISlider superclass will centre itself vertically within the view; optimal sizes are 23pt or greater.

TLTiltHighlightView *slider = [[TLTiltSlider alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), 23)];
[self.view addSubview:slider];

Slider

Alternatively to instantiating the class programmatically, you can also use Interface Builder by selecting the Identity Inspector and changing the class of a view.

Identity Inspector

You can also disable the tilt updates for older devices:

slider.tiltEnabled = NO;

Requirements

You must link with Core Motion. This project requires ARC.

About

A UISlider subclass which adjusts its appearance based on the positional attitude of an iOS device.

Resources

License

Stars

Watchers

Forks

Packages

No packages published