UISwitch

来源:互联网 发布:xp网络共享一键设置 编辑:程序博客网 时间:2024/06/08 09:50

          

UISwitch控件

           UISwitch *infoSwitch = [[UISwitch alloc]initWithFrame:CGRectMake(20 , 200 , 20, 10)];

            [infoSwitch setOn:YES];
            [infoSwitch addTarget:self action:@selector(switchClick:) forControlEvents:UIControlEventValueChanged];

            [self.view addSubview:infoSwitch];



- (void)switchClick: (UISwitch *)sender {
    UISwitch *buttonSwitch = (UISwitch *)sender;
    BOOL isSwitchOn = buttonSwitch.isOn;
    if (isSwitchOn) {

         ///what to do...

       NSLog(@"open");

    }else {

        ///what to do...

       NSLog(@"close");
    }
}


0 0
原创粉丝点击