I'd like to change the appearance of disabled textfields, i.e. text and background color - is there an easy and legal way to achieve this?
Set the Boolean variable to false, which enables editing in the text field. When someone taps the Done button, isEditing becomes false. Set the Boolean variable to true, which disables editing in the text field.
Use the enabled: property of the TextField widget by setting it to false : TextField( enabled: false, ... ) This field won't respond to onTap events - it is similar to a disabled field in HTML.
An object that displays an editable text area in your interface.
You could subclass your UITextfield and overwrite the enabled
property like this
- (void)setEnabled:(BOOL)enabled
{
[super setEnabled:enabled];
// Do your customization here, eg:
self.backgroundColor = [UIColor blackColor];
}
Swift version:
override var isEnabled: Bool {
willSet {
backgroundColor = newValue ? UIColor.white : UIColor.black
}
}
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