开关控件的使用
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
// 开关控件的基本用法
// 创建一个显示区域
let rect = CGRect(x: 130, y: 100, width: 0, height: 0)
// 初始化开关对像
let uiSwitch = UISwitch(frame: rect)
// 默认状态设置为打开
uiSwitch.setOn(true, animated: true)
// 为开关添加状态变化事件
uiSwitch.addTarget(self, action: #selector(ViewController.switchChanged(uiSwitch:)), for: UIControlEvents.valueChanged)
self.view.addSubview(uiSwitch)
}