IOS programming
[IOS programming] Type text
이숩숩
2023. 6. 20. 01:42
원하는 글자를 화면에 입력하는 코드입니다.
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var myText: UITextField!
var screen_text:String = " "
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func Click_A(_ sender: UIButton) {
screen_text = screen_text + "A"
myText.text = screen_text
}
@IBAction func Click_B(_ sender: UIButton) {
screen_text = screen_text + "B"
myText.text = screen_text
}
@IBAction func Click_clear(_ sender: UIButton) {
screen_text = ""
myText.text = ""
}
}