01-Swift 变量常量等基础知识学习

2016-11-14  本文已影响15人  magic_pill
1.import 区别
//OC
#import "ViewController.h"
#import <Foundation/Foundation.h>
//Swift
import UIKit
import Foundation
2.创建变量
var a:Int = 2
a = 3
3.创建常量
let b = 3
//b = 4  报错
4.创建对象
let view:UIView = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
view.backgroundColor = UIColor.red

let gView:UIView = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
gView.backgroundColor = UIColor.green

view.addSubview(gView)
5.运算注意点
小结
上一篇下一篇

猜你喜欢

热点阅读