IQKeyboard manager add done button for particular text field also add done button action for that iOS swift

 Problem:

I'm using IQKeyboard manager for keyboard appearance and done button.I want to change the done button title as cancel for some textfields also some textfields i want to be as done.

I want to add action for done button for particular textfield.


Solution:

    func textFieldDidBeginEditing(_ textField: UITextField) {

        IQKeyboardManager.shared.toolbarDoneBarButtonItemText = "Cancel" // you can compare the textfield here and change the title as per your requirement


    }


for done button action add the below code


        tf.keyboardToolbar.doneBarButton.setTarget(self, action: #selector(doneButtonClicked))


    @objc func doneButtonClicked() {

tf.resignFirstResponder()

}

Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift