import UIKit
class ViewController: UIViewController {
@IBOutlet weak var labelTop: UILabel!
@IBOutlet weak var labelDown: UILabel!
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.
}
@IBAction func numberClick(sender: UIButton) {
labelTop.text = labelTop.text! + sender.currentTitle!
}
@IBAction func clearClick(sender: UIButton) {
labelTop.text = ""
labelDown.text = ""
}
@IBAction func submitClick(sender: UIButton) {
//labelTop.text?.characters.count
if labelTop.text?.lengthOfBytesUsingEncoding(NSUTF8StringEncoding) == 10 {
labelDown.text = "撥打電話:" + labelTop.text!
}else{
labelDown.text = "長度不足10"
}
}
}
沒有留言:
張貼留言