I have set a custom UIDatePicker to UITextField. I can detect when it closes, because I have "Done" button in there. How can I detect when it's opened? I want to make screen darker while user is selecting.
This relies on the UITextFieldDelegate to determine when the textfield becomes active. The key to this working in your situation is to check the inputView of your textField to see if it matches the pickerView you are using. Ideally, the only change you will need to make is to replace the name of the pickerView variable I used.
func textFieldDidBeginEditing(textField: UITextField) {
if textField.inputView == pickerView {
// Do your thing here
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With