//Switch宽高无法设置
//let GPLswitch = UISwitch(frame: CGRect(x: 100, y: 200, width: 200, height: 200))
let GPLswitch = UISwitch()
GPLswitch.center = CGPoint(x: 100, y: 200)
//设置默认值
GPLswitch.isOn = true
GPLswitch.addTarget(self, action: #selector(switchClick), for: .valueChanged)
self.view.addSubview(GPLswitch)
func switchClick()
{
print("点击了")
}