[ios]swift uitextview keyboard done
uitextview hite keyboard 시키고 싶다..
그럴려면..
extension UITextField
{
func addDoneButton(title: String, target: Any, selector: Selector) {
let toolBar = UIToolbar(frame: CGRect(x: 0.0,
y: 0.0,
width: UIScreen.main.bounds.size.width,
height: 44.0))//1
let flexible = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)//2
let barButton = UIBarButtonItem(title: title, style: .plain, target: target, action: selector)//3
toolBar.setItems([flexible, barButton], animated: false)//4
self.inputAccessoryView = toolBar//5
}
}
self.mEtTextField.addDoneButton(title: "Done", target: self, selector: #selector(clickDone(sender:)))
@objc func clickDone(sender: Any) {
self.view.endEditing(true)
}
[참조] http://www.swiftdevcenter.com/uitextview-dismiss-keyboard-swift/
'ios,swift' 카테고리의 다른 글
[ios] push test site (0) | 2020.01.31 |
---|---|
[ios] swift Found an unexpected Mach-O header code: 0x72613c21 해결방법 (0) | 2020.01.31 |
[ios] swift html 적용시키기 (0) | 2020.01.31 |
[ios] swift NSMutableAttributedString color 부분변경방법 (0) | 2020.01.31 |
[ios] swift linker command failed with exit code 1 해결방법 (0) | 2020.01.30 |