Uikit Learn the use of slider control UISlider
Slider:
Sliders enable users to interactively modify some adjustable the value in a app, such as speaker volume or screen brightness.
UISlider:
A UISlider object is a visual control used to select a single value from a continuous range of values. Sliders is always displayed as horizontal bars. An indicator, or thumb, notes the current value of the slider and can is moved by the user to the setting.
UISlider The creation of the control:
(1) using Ctrl+drag drag-and-drop method in Stroyboard to create
(2) Code creation
Create a slider control let Slider=uislider (Frame:cgrectmake (0,0,300,50))//Set sliderslider.center= Self.view.centerslider.minimumvalue=0//min slider.maximumvalue=1//MAX slider.value=0.5//current default Self.view.addSubview (Slider)
import uikitclass viewcontroller: uiviewcontroller { override Func viewdidload () { super.viewdidload () // do any additional setup after loading the view, typically from a nib. let slider=uislider (Frame:cgrectmake (0,0,300,50)) slider.center=self.view.center slider.minimumvalue=0 //Minimum Value slider.maximumvalue=1 //Maximum Value slider.value=0.5 //Current default value slider.continuous=false  ///slide stops before triggering valuechanged events //Add response Event slider.addtarget (self, action: " Sliderdidchanged: ", forcontrolevents:uicontrolevents.valuechanged) //set the color of the side slots slider.minimumtracktintcolor=uicolor.redcolor () //left slot color, default is blue slider.maximumtracktintcolor=uicolor.browncolor () //right slot color, default is gray self.view.addsubview (slider) } //Response Event Function func sliderdidchanged (slider:UISlider) { //value of output control Print (Slider.value) } override func didreceivememorywarning () { Super.didreceivememorywarning () // Dispose of any resources that can be recreated. }}
[Swift Learning] Uikit Learn the use of slider control UISlider