UISwitch 开关控件

UISwitch iOS中的开关控件,只有两种状态,打开或关闭.

aSwitch.tintColor = [UIColor redColor]; //关闭状态下的渲染颜色

aSwitch.onTintColor = [UIColor blueColor]; //打开状态下的渲染颜色.

aSwitch.on = NO; //将其显示状态为打开 (默认关闭).

aSwitch.thumbTintColor = [UIColor blackColor]; //改变switch开关按钮的颜色.

[aSwitch  addTarget:self action:@selector(handleSwitch:) forControlEvent:UIControlEventValueChanged];//给switch添加点击事件

原文地址:https://www.cnblogs.com/lion-witcher/p/5095008.html