UISwitch

创建Switch

let mySwitch = UISwitch(frame: CGRectMake(100,100,0,0))
mySwitch.tag = 101
self.view.addSubview(mySwitch)

开关与事件

mySwitch.on = false
mySwitch.addTarget(self, action: Selector("switchDidChange"), forControlEvents: UIControlEvents.ValueChanged)
func switchDidChange(){
    let swit = self.view.viewWithTag(101) as! UISwitch
    print(swit.on)
}

  

来源: http://www.cnblogs.com/spaceID/p/4976904.html

posted @ 2015-11-19 10:48  寻找小猪  阅读(143)  评论(0编辑  收藏  举报