iOS开发入门请参考上一篇iOS开发入门
入门篇中的label控件是最基础的展示控件,本篇介绍该控件和代码关联,在代码中可以动态修改label文本属性。
定义变量
首先打开工程中ViewController.swift文件,初始代码如下:
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.