------------------------------------------------------------------------------------------
//// VIEwController.swift// UISwitchSample//// Created by jinnchang on 15/4/2.// copyright (c) 2015年 Jinn Chang. All rights reserved.//import UIKitclass VIEwController: UIVIEwController { var simpleSwitch: UISwitch! overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() // Do any additional setup after loading the vIEw,typically from a nib. simpleSwitch = UISwitch(frame: CGRectMake(30,50,self.vIEw.frame.size.wIDth - 60,100)) simpleSwitch.on = true simpleSwitch.addTarget(self,action: "switchChange:",forControlEvents: .ValueChanged) self.vIEw.addSubvIEw(simpleSwitch) } overrIDe func dIDReceiveMemoryWarning() { super.dIDReceiveMemoryWarning() // dispose of any resources that can be recreated. } /// 响应开关控制事件 func switchChange(sender: UISwitch) { if sender.on { println("switch is on") } else { println("switch is off") } }}------------------------------------------------------------------------------------------
GitHub 上项目地址:UISwitchSample
控件更多相关属性及方法参考:UISwitch Class Reference 文章最后更新时间:2015年4月3日10:48:31 总结
以上是内存溢出为你收集整理的Swift 简单控件示例:开关(UISwitch)全部内容,希望文章能够帮你解决Swift 简单控件示例:开关(UISwitch)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)