ios-UISwitch
let mySwitch:UISwitch = UISwitch(frame: CGRect(x:0,y:80,witdh:10,height:10)
//添加触发事件
mySwitch.addTarget(self,action:Selector("SwitchClick:")),forControlEvents:UIControlEvents.valueChanged)
//设置滑块的颜色
myswitch.thumbTintcolor = UIColor.red
//设置开关开启的颜色
mySwitch.ontintColor = UIColor.blue
//关闭开关的颜色
mySwitch.tintColor = UIColor.blue
//函数
func switchClick(swi:UISwitch){
if swi.on{
self.view.backgroudColor = UIColor.gray
}else{
self.view.backgroudcolor = UIcolor.blue
}
}