iOS Swift 初级

1.AppDelegate 入口

1
2
3
4
5
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
self.window!.backgroundColor = UIColor.whiteColor()
var viewController:ViewController = ViewController();
self.window!.rootViewController = viewController
self.window!.makeKeyAndVisible()

2.按钮

1
2
3
4
5
6
7
8
9
10
//创建
var recordBtn: UIButton = UIButton.buttonWithType(.System) as UIButton
recordBtn.setTitle("record", forState:.Normal)
recordBtn.frame = CGRectMake(110, 20, 100, 50)
recordBtn.addTarget(self, action:Selector("onRecord"), forControlEvents:.TouchUpInside)
self.view.addSubview(recordBtn)
//点击按钮方法
func onRecord(){
}