iOS – UISlider Example…

UISlider is an visual object used to select a single value from a continuous range of values.Values can be selected by sliding.

Step 1: Drag and drop a UITextField and a UISlider in the xib.

Step 2: Set the reference for UISlider and UITextField in the .h file.UISlider as ‘slider’ and UITextField as ‘sliderTextField’.

@property (weak, nonatomic) IBOutlet UISlider *slider;

@property (weak, nonatomic) IBOutlet UITextField *sliderTextField;

Step 3: Set an action method for UISlider as ‘sliderProgress’.

- (IBAction)sliderProgress:(id)sender;

Step 4: Enter this code inside the method ‘sliderProgress’.

 sliderTextField.text = [NSString stringWithFormat:@"%f",slider.value];

Step 5: We are done now,Run the Program !