UISlider *slider = [[UISlider alloc]init];
slider.frame = CGRectMake(10, 100, 300, 20);
slider.backgroundColor = [UIColor redColor];
// 设置当前值
slider.value = 0.5;
// 设置滑动条事件
[slider addTarget:self action:@selector(sliderChange:) forControlEvents:UIControlEventValueChanged];
// 设置最小值
slider.minimumValue = 100;
// 设置最大值
slider.maximumValue = 101;
// 设置最小值一侧的图片
// slider.minimumValueImage = [UIImage imageNamed:@"image/background.png"];
// 设置最大值一侧的图片
// 设置最小值一侧的轨道颜色
slider.minimumTrackTintColor = [UIColor whiteColor];
// 设置最大值一侧的轨道颜色
slider.maximumTrackTintColor = [UIColor blackColor];
// 设置滑块颜色
slider.thumbTintColor = [UIColor yellowColor];
// 设置值
[slider setValue:100.5 animated:YES];
// 设置滑块图片
//[slider setThumbImage:[UIImage imageNamed:@"image/background.png"] forState:UIControlStateNormal];
// 设置最小值轨道图片颜色(
[self.window addSubview:slider];
[slider release];
UISwitch *uiSwitch= [[UISwitch alloc]init];
uiSwitch.frame = CGRectMake(10, 200, 300, 100);
// 设置是否开启状态,只可以得到值,不可以赋值
if (uiSwitch.isOn) {
NSLog(@"开启状态");
}else
{
NSLog(@"关闭状态");
}
uiSwitch.onTintColor = [UIColor blueColor];
[self.window addSubview:uiSwitch];
uiSwitch.thumbTintColor = [UIColor greenColor];
[uiSwitch release];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
slider.frame = CGRectMake(10, 100, 300, 20);
slider.backgroundColor = [UIColor redColor];
// 设置当前值
slider.value = 0.5;
// 设置滑动条事件
[slider addTarget:self action:@selector(sliderChange:) forControlEvents:UIControlEventValueChanged];
// 设置最小值
slider.minimumValue = 100;
// 设置最大值
slider.maximumValue = 101;
// 设置最小值一侧的图片
// slider.minimumValueImage = [UIImage imageNamed:@"image/background.png"];
// 设置最大值一侧的图片
// 设置最小值一侧的轨道颜色
slider.minimumTrackTintColor = [UIColor whiteColor];
// 设置最大值一侧的轨道颜色
slider.maximumTrackTintColor = [UIColor blackColor];
// 设置滑块颜色
slider.thumbTintColor = [UIColor yellowColor];
// 设置值
[slider setValue:100.5 animated:YES];
// 设置滑块图片
//[slider setThumbImage:[UIImage imageNamed:@"image/background.png"] forState:UIControlStateNormal];
// 设置最小值轨道图片颜色(
[self.window addSubview:slider];
[slider release];
UISwitch *uiSwitch= [[UISwitch alloc]init];
uiSwitch.frame = CGRectMake(10, 200, 300, 100);
// 设置是否开启状态,只可以得到值,不可以赋值
if (uiSwitch.isOn) {
NSLog(@"开启状态");
}else
{
NSLog(@"关闭状态");
}
uiSwitch.onTintColor = [UIColor blueColor];
[self.window addSubview:uiSwitch];
uiSwitch.thumbTintColor = [UIColor greenColor];
[uiSwitch release];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;