기록/공부기록👩🏻‍💻

[공부기록]100일_29일차

lingk 2020. 10. 5. 23:06

키보드 done버튼

    //textView 키보드에 done버튼을 만들어 내리기
    func textViewDoneBtnMake(text_view : UITextView) {
        let ViewForDoneButtonOnKeyboard = UIToolbar()
        ViewForDoneButtonOnKeyboard.sizeToFit()
        let btnDoneOnKeyboard = UIBarButtonItem(title: "Done", style: .plain, target: self, action: #selector(self.doneBtnFromKeyboardClicked))
        ViewForDoneButtonOnKeyboard.items = [btnDoneOnKeyboard]
        
        text_view.inputAccessoryView = ViewForDoneButtonOnKeyboard
        
    }
    @objc func doneBtnFromKeyboardClicked (sender: Any) {
        print("Done Button Clicked.") //Hide Keyboard by endEditing or Anything you want.
            self.view.endEditing(true)
        
    }

viewDidLoad에서 해당 함수를 실행시키고, 텍스트뷰를 넘겨주었다.

 

 

 

 

반응형

'기록 > 공부기록👩🏻‍💻' 카테고리의 다른 글

[공부기록]100일_31일차  (0) 2020.10.07
[공부기록]100일차_30일  (0) 2020.10.06
[공부기록]100일_28일차  (0) 2020.10.04
[공부기록]100일_27일차  (0) 2020.10.03
[공부기록]100일_26일차  (0) 2020.10.02