Welcome to the documentation for the DoneCancelNumberPadToolBar library!
Installation Guide
To start using the DoneCancelNumberPadToolBar library in your project, follow the steps below:
- Open your project in Xcode.
- Navigate to File > Add Files to [Your Project Name].
- Select the DoneCancelNumberPadToolBar.swift file from the library’s source folder.
- Make sure the library is added to your target.
Integration Guide
To integrate the DoneCancelNumberPadToolBar library into your project, follow the steps given below:
Step 1: Import
Add the following import statement at the top of the relevant file:
import DoneCancelNumberPadToolBar
Step 2: UITextField Usage
Use the following code to add a toolbar with “Done” and “Cancel” buttons to the keyboard of a UITextField:
let textField = UITextField()
textField.inputAccessoryView = DoneCancelNumberPadToolBar.addToolbarToTextField(textField, target: self, cancelAction: #selector(cancelButtonTapped), doneAction: #selector(doneButtonTapped))
Make sure to implement the corresponding cancel and done button action methods in your view controller.
Step 3: UITextView Usage
Use the following code to add a toolbar with “Done” and “Cancel” buttons to the keyboard of a UITextView:
let textView = UITextView()
textView.inputAccessoryView = DoneCancelNumberPadToolBar.addToolbarToTextView(textView, target: self, cancelAction: #selector(cancelButtonTapped), doneAction: #selector(doneButtonTapped))
Make sure to implement the corresponding cancel and done button action methods in your view controller.
Example Usage
Here is an example illustrating the usage of the DoneCancelNumberPadToolBar library:
// Import statement
import DoneCancelNumberPadToolBar
class MyViewController: UIViewController {
// UITextField usage example
let textField = UITextField()
override func viewDidLoad() {
super.viewDidLoad()
// Add toolbar to UITextField
textField.inputAccessoryView = DoneCancelNumberPadToolBar.addToolbarToTextField(textField, target: self, cancelAction: #selector(cancelButtonTapped), doneAction: #selector(doneButtonTapped))
}
// UITextView usage example
let textView = UITextView()
override func viewDidLoad() {
super.viewDidLoad()
// Add toolbar to UITextView
textView.inputAccessoryView = DoneCancelNumberPadToolBar.addToolbarToTextView(textView, target: self, cancelAction: #selector(cancelButtonTapped), doneAction: #selector(doneButtonTapped))
}
@objc func cancelButtonTapped() {
// Handle cancel button action
}
@objc func doneButtonTapped() {
// Handle done button action
}
}
Conclusion
Congratulations! You have successfully integrated the DoneCancelNumberPadToolBar library into your project. You can now enjoy the added functionality of “Done” and “Cancel” buttons in the keyboard toolbar for your UITextField and UITextView.