UISwitch 开关控件

时间:2022-05-17 07:19:17

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添加点击事件