前端之家收集整理的这篇文章主要介绍了
Swift Playground,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
- //: Playground - noun: a place where people can play
- // 让开发和 '玩' 一样
-
- /*
- 左边: 代码区
- 右边: 运行结果显示区
-
- 无需编译 直接看到开发效果
-
- 作用: 方便初学者迅速演练
- 方便测试代码
-
-
-
- */
-
-
- /*
- 语法:
- 初始化
- OC alloc / initWithXXX alloc / init
- Swift 类名(XXX:) ()
-
- 方法调用 点语法调用方法
- OC: [UIColor redColor];
- swift: UIColor.redColor
-
- 枚举:
- OC: UIButtonTypeContactAdd
- Swfit: . 分开 快捷实用 选中枚举 -> enter -> 右键 -> . -> 选择枚举
- 枚举 . 前半部分可以省略
- 注意 省略前半部分枚举可能没有只能提示
-
-
- swift语言 更加的简洁
- */
-
- import UIKit
-
- var str = "Hello,playground"
-
- let v = UIView(frame: CGRectMake(0,100,100))
- v.backgroundColor = UIColor.redColor()
-
- let btn = UIButton(type: .ContactAdd)
- btn.center = v.center
- v.addSubview(btn)
-
- //let image = UIImage(named: "xxxx")