UISwitch 详解

1 UISwitch *sw = [[UISwitch alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
2     sw.on = YES;    // 开启
3     [sw addTarget:self
4            action:@selector(mySwitch:)
5  forControlEvents:UIControlEventValueChanged]; // 值改变时触发此事件

 

你可能感兴趣的:(switch)