簡單的購物清單

一樣出現很多想法

先上gif圖

再附上程式碼

@IBOutlet weak var myText1: UITextField!@IBOutlet weak var myText2: UITextField!@IBOutlet weak var myText3: UITextField!@IBOutlet weak var myText4: UITextField!@IBOutlet weak var totalNT: UITextField!@IBOutlet weak var stepperOutlet1: UIStepper!@IBOutlet weak var stepperOutlet2: UIStepper!@IBOutlet weak var stepperOutlet3: UIStepper!@IBOutlet weak var stepperOutlet4: UIStepper!func tolalPrice(){var total = Int(stepperOutlet1.value * 45 + stepperOutlet2.value * 60)total = total + Int(stepperOutlet3.value * 80 + stepperOutlet4.value * 65)totalNT.text = "\(total)" + " 元"}@IBAction func myStepper1(_ sender: UIStepper) {let sender = Int(sender.value)myText1.text = "\(sender)"tolalPrice()}@IBAction func myStepper2(_ sender: UIStepper) {let sender = Int(sender.value)myText2.text = "\(sender)"tolalPrice()}@IBAction func myStepper3(_ sender: UIStepper) {let sender = Int(sender.value)myText3.text = "\(sender)"tolalPrice()}@IBAction func myStepper4(_ sender: UIStepper) {let sender = Int(sender.value)myText4.text = "\(sender)"tolalPrice()}@IBAction func clearButton(_ sender: UIButton) {myText1.text = "0"myText2.text = "0"myText3.text = "0"myText4.text = "0"totalNT.text = "0 元"stepperOutlet1.value = 0stepperOutlet2.value = 0stepperOutlet3.value = 0stepperOutlet4.value = 0}

主要是模仿類似畫面功能

是可以延伸更多

--

--