美文网首页
Swift开关按钮(UISwitch)的用法

Swift开关按钮(UISwitch)的用法

作者: MangoJ | 来源:发表于2016-06-27 13:20 被阅读492次

    import UIKit

    class ViewController: UIViewController        ,UITextFieldDelegate,UITextViewDelegate,UIActionSheet  Delegate,UIAlertViewDelegate{
    var uiswitch:UISwitch!;
    override func viewDidLoad() {
        super.viewDidLoad()
    
        uiswitch = UISwitch()
        uiswitch.frame = CGRectMake(10, 230, 200, 30)
        uiswitch.on = true
        uiswitch.addTarget(self, action: Selector("switchDidChange"), forControlEvents: UIControlEvents.ValueChanged)
        self.view.addSubview(uiswitch)
    
      }
    
    func switchDidChange(){
        
       print(uiswitch.on)
       
    }
    
    }

    相关文章

      网友评论

          本文标题:Swift开关按钮(UISwitch)的用法

          本文链接:https://www.haomeiwen.com/subject/bgpzdttx.html