IOS开关控件,滑块控件和分段控件的使用
- (IBAction)withSwitch:(UISwitch *)sender {
UISwitch *withSwitch = (UISwitch *)sender;
if (withSwitch.isOn) {
__switchLabel.text = @"ON";
}else{
__switchLabel.text = @"OFF";
}
[self.secondSwitch setOn:withSwitch.isOn animated:YES];
}
- (IBAction)changeSliderValue:(UISlider *)sender {
UISlider *slider = (UISlider *)sender;
float value = slider.value;
NSString *str = [NSString stringWithFormat:@"%f", value];
__switchLabel.text = str;
}
- (IBAction)touchDwon:(UISegmentedControl *)sender {
UISegmentedControl *segment = (UISegmentedControl *)sender;
NSInteger value = segment.selectedSegmentIndex;
__switchLabel.text = [NSString stringWithFormat:@"%ld", (long)value];
}