Swift Playground

前端之家收集整理的这篇文章主要介绍了Swift Playground前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
  1. //: Playground - noun: a place where people can play
  2. // 让开发和 '玩' 一样
  3.  
  4. /*
  5. 左边: 代码
  6. 右边: 运行结果显示
  7.  
  8. 无需编译 直接看到开发效果
  9.  
  10. 作用: 方便初学者迅速演练
  11. 方便测试代码
  12.  
  13.  
  14.  
  15. */
  16.  
  17.  
  18. /*
  19. 语法:
  20. 初始化
  21. OC alloc / initWithXXX alloc / init
  22. Swift 类名(XXX:) ()
  23.  
  24. 方法调用 点语法调用方法
  25. OC: [UIColor redColor];
  26. swift: UIColor.redColor
  27.  
  28. 枚举:
  29. OC: UIButtonTypeContactAdd
  30. Swfit: . 分开 快捷实用 选中枚举 -> enter -> 右键 -> . -> 选择枚举
  31. 枚举 . 前半部分可以省略
  32. 注意 省略前半部分枚举可能没有只能提示
  33.  
  34.  
  35. swift语言 更加的简洁
  36. */
  37.  
  38. import UIKit
  39.  
  40. var str = "Hello,playground"
  41.  
  42. let v = UIView(frame: CGRectMake(0,100,100))
  43. v.backgroundColor = UIColor.redColor()
  44.  
  45. let btn = UIButton(type: .ContactAdd)
  46. btn.center = v.center
  47. v.addSubview(btn)
  48.  
  49. //let image = UIImage(named: "xxxx")

猜你在找的Swift相关文章