//

// ViewController.swift

// UILabelTest

//

// Created by mac on 15/6/23.

// Copyright (c) 2015年 fangyuhao. All rights reserved.

//

import UIKit

class ViewController: UIViewController {

var uiswitch:UISwitch!;

override func viewDidLoad() {
super.viewDidLoad() uiswitch = UISwitch()
//设置位置
uiswitch.center = CGPointMake(100, 50)
//设置默认值
uiswitch.on = true
uiswitch.addTarget(self, action: Selector("switchDidChange"), forControlEvents: UIControlEvents.ValueChanged) self.view.addSubview(uiswitch)
// Do any additional setup after loading the view, typically from a nib.
} override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func switchDidChange(){
println(uiswitch.on)
}

}

UISwitch swift的更多相关文章

  1. swift系统学习控件篇:UIbutton+UIlabel+UITextField+UISwitch+UISlider

    工作之余,学习下swift大法.把自己的学习过程分享一下.当中的布局很乱,就表在意这些细节了.直接上代码: UIButton+UILabel // // ViewController.swift // ...

  2. iOS开发——UI篇Swift篇&UISwitch/UIStepper

    UISwitch/UIStepper override func viewDidLoad() { super.viewDidLoad() titleLabel.text = titleString / ...

  3. Swift - 开关按钮(UISwitch)的用法

    下面演示如何创建开关,以及监听它值的改变,代码如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 class ViewController: UIV ...

  4. swift 实践- 07 -- UISwitch 开关

    import UIKit class ViewController: UIViewController { var uiswitch: UISwitch? override func viewDidL ...

  5. swift - UISwitch 的用法

    具体代码如下,和oc的使用没有差别: 创建: let hswitch = UISwitch() /*创建开关,以及监听它值的改变,代码如下*/ //开关位置 hswitch.center = CGPo ...

  6. swift学习之UI控件(一)

    // //  ViewController.swift //  test // //  Created by chuangqu on 15/7/23. //  Copyright (c) 2015年 ...

  7. Swift - 让程序挂起后,能在后台继续运行任务

    1,程序的挂起和退出 由于iOS设备资源有限.当用户点击了home键,或者另一个应用程序启动了.那么原先那个程序便进入后台被挂起,不是退出,只是停止执行代码,同时它的内存被锁定.当应用程序恢复时,它会 ...

  8. 1. Swift基本变量|运算符|控制流

    Swift基于cocoa Touch框架,苹果官方为了保证Swift的可靠性,结合多种语言的特性,同时独立了一套属于自己的单独语言,结合了C,C++,OC,Java等语言. 基本变量: 1 . swi ...

  9. iOS - UISwitch

    前言 NS_CLASS_AVAILABLE_IOS(2_0) __TVOS_PROHIBITED @interface UISwitch : UIControl <NSCoding> @a ...

随机推荐

  1. Dynamic AX 4.0 用户组权限SecurityKey

    UserId _userId = "IT001"; UserGroupId _userGroupId = "ABC_1"; DomainId _domainId ...

  2. 【MySQL】Sysbench性能测试

    两台MySQL配置不一样,要测试下性能差别 [m1] long_query_time = 0.1 log_slave_updates innodb_flush_log_at_trx_commit [m ...

  3. 对js闭包的粗浅理解

    只能是粗浅的,毕竟js用法太灵活. 首先抛概念:闭包(closure)是函数对象与变量作用域链在某种形式上的关联,是一种对变量的获取机制.这样写鬼能看懂. 所以要大致搞清三个东西:函数对象(funct ...

  4. CICS中设置程序常驻内存

    CICS中设置程序常驻内存 Permanent=no 修改为Permanent=yse --------------------- 对CICS的参数进行调节,RD中

  5. .NET Web开发总结

    在aspx文件中  创建控件 在右下角有控件信息 按类排序 会将控件信息安装类排序 点击控件 会增加属性页面的分页[事件]页面  可以增加其事件函数 字符串操作及其时间操作 fn_name.Inser ...

  6. POI中设置Excel单元格格式样式(居中,字体,边框等)

    创建sheet什么的就不多说了,直接进入正题 HSSFCellStyle cellStyle = wb.createCellStyle();   一.设置背景色: cellStyle.setFillF ...

  7. javascript的变量,传值和传址,参数之间关系

    先把收获晾一下: 1.javascrip变量包含两种类型的值,一种为引用类型的值,一种是基本类型的值.引用类型包括:Array,Object,Function(可以这么理解,非基本类型的都是引用类型) ...

  8. js 月历 时间函数 月份第一天 星期的判断

    返回值为0-6,其中返回值0为星期天:如同,php中的日期函数一样判断.

  9. mysql 导入导出数据库、数据表

    Linux下 均在控制台下操作. 导入数据库: 前提:数据库和数据表要存在(已经被创建) (1)将数据表 test_user.sql 导入到test 数据库的test_user 表中 [root@te ...

  10. SBM is Not Sale And Run Company

    data = """ Well,We will bet you dollars to donuts,there are so many crusher provider ...