import UIKit
import XCPlayground

class ViewController: UIViewController {
func action() { print("Bing!") }

override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .whiteColor()

let mySwitch : UISwitch = {
view.addSubview($0)
CenterViewInSuperview($0, horizontal: true, vertical: true)
$0.addTarget(self, action: "action", forControlEvents: .TouchUpInside)
return $0
}(UISwitch())

let _ : UILabel = {
view.addSubview($0)
CenterViewInSuperview($0, horizontal: true, vertical: false)
$0.text = "Toggle me"
$0.font = UIFont.boldSystemFontOfSize(36)
ConstrainViews("V:[view1]-30-[view2]", views: $0, mySwitch)
return $0
}(UILabel())
}
}

ViewController()
XCPlaygroundPage.currentPage.liveView = ViewController()
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true

swift语言点评十五-$0的更多相关文章

  1. swift语言点评十九-类型转化与检查

    1.oc比较: -(BOOL) isKindOfClass: classObj判断是否是这个类或者这个类的子类的实例 -(BOOL) isMemberOfClass: classObj 判断是否是这个 ...

  2. swift语言点评十八-异常与错误

    1.错误类型与枚举的结合 enum VendingMachineError: Error { case invalidSelection case insufficientFunds(coinsNee ...

  3. swift语言点评十四-继承

    Overriding A subclass can provide its own custom implementation of an instance method, type method, ...

  4. swift语言点评十二-Subscripts

    Classes, structures, and enumerations can define subscripts, which are shortcuts for accessing the m ...

  5. swift语言点评十-Value and Reference Types

    结论:value是拷贝,Reference是引用 Value and Reference Types Types in Swift fall into one of two categories: f ...

  6. swift语言点评十六-Initialization && Deinitialization

    initial value:必须初始化.不影响观察者 Classes and structures must set all of their stored properties to an appr ...

  7. Swift语言指南(十)--字符串与字符

    原文:Swift语言指南(十)--字符串与字符 字符串是一段字符的有序集合,如"hellow,world"或"信天翁".Swift 中的字符串由 String ...

  8. swift语言点评二十-扩展

    结论:扩展无法修改原来的数据结构. Extensions can add new functionality to a type, but they cannot override existing ...

  9. swift语言点评四-Closure

    总结:整个Closure的作用在于简化语言表述形式. 一.闭包的简化 Closure expression syntax has the following general form: { () -& ...

随机推荐

  1. React router内是如何做到监听history改变的

    问题背景 今天面试的时候,被问到这么个问题.在html5的history情况下,pushstate和replacestate是无法触发pushstate的事件的,那么他是怎么做到正确的监听呢?我当时给 ...

  2. java8 stream 流 例子

    Trader raoul = new Trader("Raoul", "Cambridge"); Trader mario = new Trader(" ...

  3. 任何抛开业务谈大数据量的sql优化都是瞎扯

    周三去某在线旅游公司面试.被问到了一个关于数据量大的优化问题.问题是:一个主外键关联表,主表有一百万数据,外键关联表有一千万的数据,要求做一个连接. 本人接触过单表数据量最大的就是将近两亿行历史数据( ...

  4. 05 ADO.net

    ADO.NET就是一组类库 操作数据库用的.

  5. 简述vuex的数据传递流程

    简述vuex的数据传递流程 当组件进行数据修改的时候我们需要调用dispatch来触发actions里面的方法.actions里面的每个方法中都会有一个commit方法,当方法执行的时候会通过comm ...

  6. iText、poi操作word2007(读取,生成)

    关于生成word文件以及插入文字.表格.图片等功能,我使用了poi和itext,因为poi插入图片的jar包我在网上查并不是太完全,也可能我没找到如何使用,所以插入图片我用的是itext iText所 ...

  7. mybatis中根据日期模糊查询

    首先设置起始日期startDate和结束日期endDate,数据库中日期字段为achive_time,表名为dos_dossier<select id="getDossiers&quo ...

  8. Mysql学习总结(32)——MySQL分页技术详解

    1.什么是数据分页:数据分页就是将很多条记录像书本一样分页,每页显示多少行记录: 2.为什么要数据分页:当我们进行sql语句查询时,假如数据有成千上万行记录,如果在同一个页面去显示,那这个页面得有多大 ...

  9. 2015 Multi-University Training Contest 4 hdu 5338 ZZX and Permutations

    ZZX and Permutations Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/O ...

  10. CSVHelper读出乱码 解决方案

    using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read)) using (StreamRe ...