80 likes | 192 Vues
This guide provides a step-by-step explanation on how to effectively use Slider, Switch, and Segment controls in iOS development. Learn how to set up a Slider with defined minimum and maximum values, maintain continuous updates, and reflect changes in the UI. Discover how to implement Switch controls for toggling states and manage Segment controls for displaying different content. Key code snippets are included for practical implementation, making it easier for developers to integrate these controls into their applications.
E N D
How to use Slider 1 What’s the slider? (1) A slider lets you choose a number in a given range. (2) set the Minimum value to 1,the Maximum value to 100,and the current value to 50.
How to use Slider (3) Continuous checkbox checked-this ensures a continuous flow of events as the slider’s value changes. (4) need an outlet that points to the label so that we can update the label’s value when the slider is used.
How to use Slider 2 Some improtant code { int currentValue=lroundf(sender.value); self.sliderLabel.text=[NSString stringWithFormat:@”%d”,currentValue]; }
How to use Switch 1 What’s the slider? It is samll controls that can have only two states:on and off.
How to use Switch 2 Some improtant code. { BOOL flag=sender.isOn; [self.leftSwitch setOn:flag animated:YES]; [self.rightSwitch setOn:flag animated:YES]; }
How to use Segment 1 What’s the segment? (1) It is to show different things. (2) the first section has an index of 0.
How to use Segment 2 Some improtant code. if (sender.selectedSegmentIndex==0){ self.leftSwitch.hidden=NO; self.rightSwitch.hidden=NO; self.segmentButton.hidden=YES; }
How to use Segment else{ self.leftSwitch.hidden=YES; self.rightSwitch.hidden=YES; self.segmentButton.hidden=NO; }