看图
下面附上代码import UIKit
class ViewController: UIViewController {
@IBOutlet weak var display: UITextField!
@IBAction func xianshi(_ sender: UIButton) {
display.text="HelloWorld"
}
@IBAction func qingkong(_ sender: UIButton) {
display.text=" "
}
}
最后看模拟器效果图