IOS UISwitch 开关视图

let rect = CGRect(x:130, y:100, width:0, height:0)
let uiSwitch = UISwitch(frame:rect)
uiSwitch.setOn(true, animated:true)
uiSwitch.thumbTintColor = UIColor.blue
uiSwitch.onTintColor = UIColor.green
uiSwitch.tintColor = UIColor.brown
uiSwitch.addTarget(self, action:#selector(ViewController.switchChanged(_:)), for:
UIControlEvents.valueChanged)
self.view.addSubview(uiSwitch)

猜你喜欢

转载自blog.csdn.net/weixin_33895475/article/details/90866441