I have an app that works properly on iOS 11-13, but when I run it in iOS 14 several text fields within it are rendered with a nil, and so transparent, background color even though the background color is set to White explicitly in the Interface Builder.
I can't see anywhere in the code that uses those text fields that might mess up the background color, and these same UITextFields running under the same scenarios appear with White background on iOS 13 and below.
If I set the color explicitly in code everything works fine in iOS 14
nameTextField.backgroundColor = .white
I don't want to add redundant code just to reset the background color. Is there anything I might be missing about new UITextField behaviour in iOS 14?
Ctrl + Click on the textfield in interface builder. Drag from EditingChanged to inside your view controller class in the assistant view. Name your function ("textDidChange" for example) and click connect.
You can't do this – UIStackView is a non-drawing view, meaning that drawRect() is never called and its background color is ignored. If you desperately want a background color, consider placing the stack view inside another UIView and giving that view a background color. Reference from HERE.
To do the inverse, String to Int (say you want to take the value a user has typed in), you can do the following: if let myInt = yourTextField. text. toInt() { VAT = myInt; } else { // Show some error to the user. }
TextField view doesn't provide a way to add background color but we can use the background modifier to add color to the TextField.
Going through the storyboards and resetting the background color of the text fields did the trick for me in Xcode 12 GM.
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