码迷,mamicode.com
首页 > 移动开发 > 详细

iOS开发之计算器

时间:2017-07-26 18:03:34      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:one   over   import   loading   ios开发   resources   swift   iba   tle   

本项目基于swift3.0的语法。

 1 //
 2 //  ViewController.swift
 3 //  加法计算器
 4 //
 5 //  Created by 葛杨杨 on 2017/7/25.
 6 //  Copyright ? 2017年 葛杨杨. All rights reserved.
 7 //
 8 
 9 import UIKit
10 
11 class ViewController: UIViewController {
12     
13     @IBOutlet weak var textOne: UITextField!
14     @IBOutlet weak var textTwo: UITextField!
15     @IBOutlet weak var resultLabel: UILabel!
16 
17        
18     @IBAction func calculate() {
19         var num1 = Int(self.textOne.text!)
20         var num2 = Int(self.textTwo.text!)
21     
22         var resultNum = num1! + num2!
23         
24         var resultStr = "\(resultNum)"
25             
26         self.resultLabel.text = resultStr;
27         
28     }
29 
30     override func viewDidLoad() {
31         super.viewDidLoad()
32         // Do any additional setup after loading the view, typically from a nib.
33     }
34 
35     override func didReceiveMemoryWarning() {
36         super.didReceiveMemoryWarning()
37         // Dispose of any resources that can be recreated.
38     }
39 
40 
41 }

 

iOS开发之计算器

标签:one   over   import   loading   ios开发   resources   swift   iba   tle   

原文地址:http://www.cnblogs.com/geyang/p/7239820.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!