UISwitch的用法总结开关用法

1.UISwitch的初始化

UISwitch *switchView = [[UISwitch alloc] initWithFrame:CGRectMake(4.0f, 16.0f, 100.0f, 28.0f)];

2.设置UISwitch的初始化状态

switchView.on = YES;//设置初始为ON的一边

3.UISwitch事件的响应

[switchView addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventValueChanged];
 
原文地址:https://www.cnblogs.com/zander/p/2688653.html