#66 AirPods 刻字

Storyboard:

Label、TextField

IBO

@IBOutlet weak var textLabel: UITextField! //文字輸入框@IBOutlet weak var showLabel: UILabel! //印在AirPods的文字

收鍵盤

//點空白處收鍵盤override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {self.view.endEditing(true)}//點return收鍵盤 (拉 @IBA 時 Event 選擇 Did End On Exit)@IBAction func dismissKeyboard(_ sender: Any) {}

IBA

Event 記得選 Editing Changed (輸入文字會即時改變)

@IBAction func enterText(_ sender: UITextField) {showLabel.text = sender.text}

程式碼

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jhen

Jhen

嘗試著想成為程式魔法師的少女