iOS Tutorials: Utilizing stepper to control slider

OVERVIEW

The project is using three objects from the library using stepper, slider and label. When clicked on the stepper, it will increase or decrease the slider with the label displaying the value.

Let’s get into work.

Pull out the necessary objects from the library and put it wherever you want on the screen.

Create an IBOutlet for slider and the label.

class ViewController: UIViewController {

    @IBOutlet weak var slider: UISlider!
    @IBOutlet weak var sliderStatus: UILabel!

and another IBAction for stepper

@IBAction func stepperFunction(_ sender: UIStepper) {
    slider.value = Float(sender.value)
    sliderStatus.text = Int(sender.value).description
}

With this simple codes, we will see the following magic happening:

 

The following code is uploaded on GitHub

  • Article By :
    Founder of DaddyCoding. Studied Computer Science, Information System and Information Technology at BYU-Hawaii. Currently spending most of my time researching and learning on helping to expose making iOS apps.

Random Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*