Beginner IOS development - simple addition calculator swift release

FIG look, to the inside of the first substantially Videos good Main.storyboard

used herein four Label, 2 th Button Text Field and a specific look FIG

then this is ViewController.swift (i.e. code region), Figure

attach the code (copy and paste the needs of their own very intimate bar):
Import UIKit

class ViewController: UIViewController {

@IBOutlet weak var textNumber1: UITextField!

@IBOutlet weak var textNumber2: UITextField!

@IBOutlet weak var resultLabel: UILabel!

@IBAction func calculate(_ sender: UIButton) {
    let num1 = Int(textNumber1.text!)!
    let num2 = Int(textNumber2.text!)!
    let sum = num1+num2
    resultLabel.text = String(sum)
}

}
Finally, attach the emulator running renderings

Guess you like

Origin www.cnblogs.com/xubaby0912/p/12398334.html