UISwitch 开关控件 开发笔记

  


 switchButoon = [[UISwitchalloc]initWithFrame:CGRectMake(200,200, 80,40)];

    [switchButoon addTargetself  action:@selector(switchButoonChange:)forControlEvents:UIControlEventValueChanged];


    //开关控件外部的颜色

    switchButoon.tintColor = [UIColor  redColor];


    //开关控件切换槽 颜色

    switchButoon.onTintColor = [UIColor grayColor];


    //开关控件圆按钮按钮

    switchButoon.thumbTintColor = [UIColor  blueColor];


  //  In iOS 7, this property has no effect.  在ios7 中无效果

  // this image represents the interior contents of the switch. The image you specify is composited with the switch’s         rounded bezel and thumb to create the final appearance.

    switchButoon.onImage = [UIImageimageNamed:@"swithimage.png"];

    switchButoon.offImage = [UIImageimageNamed:@"swithimage.png"];

    

    


#pragma mark--

#pragma mark -- 开关控件事件

-(void)switchButoonChange:(id)sender


{

    UISwitch *swithch = (UISwitch *)sender;

    BOOL setting = swithch.isOn;

    [swithch setOn:setting animated:YES];

    if (setting)

    {

        NSLog(@"on");

        

    }else

    {

        NSLog(@"off");

    }

    


}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值