Slider

A UISlider is similar to a UIPageControl.

Source code in Slider.zip

  1. main.m
  2. Class SliderAppDelegate
  3. Class View

Things to try

  1. What happens when you set the continuous propery of the slider to NO?

  2. Move the label up and down as the temperature changes. In the valueChanged: method of class View,
    	label.center = CGPointMake(
    		self.bounds.origin.x + self.bounds.size.width / 2,
    		self.bounds.origin.y + self.bounds.size.height / 2
    			- slider.frame.size.height / 2 - 10
    			- slider.value + slider.minimumValue
    	);
    

  3. Make the slider vertical. Add the following statement to the initWithFrame: method of class View. Multiplication by π/180 converts degrees to radians.
    	//90 degrees counterclockwise
    	slider.transform = CGAffineTransformMakeRotation(-90 * M_PI / 180);
    
    You will have to move the label out of the way.

  4. Retrofit a slider volume control into Switch.