黑马程序员IOS开关,滑块和分段控件的基本使用

------ Java培训、Android培训、iOS培训、.Net培训、期待与您交流! -------

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)ValueChaned:(id)sender {
    UISwitch *witchSwitch = (UISwitch *)sender;
    BOOL setting = witchSwitch.isOn;
    [self.LeftSwitch setOn:setting animated:YES];
    [self.RightSwith setOn:setting animated:YES];
}

- (IBAction)sliderValueChange:(id)sender {
    UISlider *slider = (UISlider *)sender;
    float nums = slider.value;
    NSString *string = [NSString stringWithFormat:@"%.2f",nums];
    NSLog(@"%.2f",0.666660);//输出两位小数
    self.SliderValue.text = string;
}

- (IBAction)touchDown:(id)sender {
    if (self.LeftSwitch.hidden == YES) {
        self.RightSwith.hidden = NO;//隐藏
        self.LeftSwitch.hidden = NO;
    }else{
        self.LeftSwitch.hidden = YES;
        self.RightSwith.hidden = YES;
    }
}
@end

你可能感兴趣的:(黑马程序员IOS开关,滑块和分段控件的基本使用)