UISlider常用功能

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;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值