Custom Keyboard For textFIeld ( Swift 4)
- Use tap Gesture Recognizer in your viewcontroller, and add Action like this below
@IBAction func didTapScreen(_ sender: Any) {
}
- First textField (textField1) setting Return Key --> Next
- Second textField (textField2) setting Return Key --> Done
- This full code in viewController.swift
import UIKit
class CustomKeyViewController: UIViewController, UITextFieldDelegate {
@IBOutlet weak var textField1: UITextField!
@IBOutlet weak var textField2: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
textField1.delegate = self
textField2.delegate = self
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
if textField1.isFirstResponder {
textField2.becomeFirstResponder()
} else {
textField2.resignFirstResponder()
}
return false
}
// need item tap gesture recognizer
@IBAction func didTapScreen(_ sender: Any) {
if textField1.isFirstResponder {
textField1.resignFirstResponder()
} else if textField2.isFirstResponder {
textField2.resignFirstResponder()
}
}
}
- This ScreenShoot KeyBoard edit (.Done) setting keyboard default
This my note as my problem and solution @luffyselah
No comments: