问题 I want to create a single extension for both UITextField and UITextView and add a below method to it: func addDoneButtonOnKeyboardWith(selector : Selector) { let keyBoardToolBar = UIToolbar(frame: CGRect(x: 0, y: 0, width: 320, height: 30)) let barButtonItem = UIBarButtonItem(barButtonSystemItem: .done, target: nil, action: selector) let flexibleSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil) keyBoardToolBar.items = [flexibleSpace, barButtonItem]