How to Implement UI Slider For Adding Custom Slider in Your Next iPhone App

Sliders are one of the great ways to allow your app users to set values in your iOS apps. And, to add such sliders, an iOS UI Slider object is used to select single value from a slider. This UI Slider is presented in horizontal bar with a thumb to select the value.

In our today’s iOS app tutorial, we’ll be developing a simple app to demonstrate how to use UI Slider to for adding custom sliders for your iPhone app development project.

Let’s Get Started

Open XCode and create a new project.


Select Single View Application as project type and click on Next.


In the next tab, write your project name and details.


Once you create new project, go to Main.storyboard and select ViewController.


Now drag and drop UISlider from “Show the object library” section.



Now, select slider and see the attribute inspector which have properties for slider. We can manage the minimum value, maximum value, current value, tack image for min, max, thumb custom image, alignment etc.


Now we set outlet UISlider in ViewController.

@IBOutlet weak var slider: UISlider!


set IBAction for UISlider, so when we move thumb of slider, value will get changed.

@IBAction func sliderValueChange(sender: AnyObject)



While creating IBAction for UISlider we need to set Event “Value Changed”.


In viewDidLoad(), we have used some properties of UISlider for set minimum, maximum and current values.

We can do more with slider.

override func viewDidLoad() {
// Do any additional setup after loading the view, typically from a nib.
//Minimum Slider Value
slider.minimumValue = 0

//Maximum Slider Value
slider.maximumValue = 100

//Current Slider Value
slider.value = 10

//If continuous = true then value change instantly else value will update once drag action completed
slider.continuous = false

And done!


Though, this was just a simple demo. It’s also possible to add a custom appearance UI Slider by adding custom images in thumb and track. But if you’re just starting out, and want to build iOS app for your startup, hire iPhone app developer for your iPhone app development project.

Grab a free copy of UISlider example demo from Github.

Author Bio
Hitesh Trivedi
Hitesh Trivedi
Designation: iOS Team Lead

Hitesh Trivedi is an iOS Team Lead at Space-O Technologies. He has over 10 years of experience in iOS app development. He has guided to develop over 100 iPhone apps with unique features and functionalities. He has special expertise in Swift and Objective-C.