iOS dark mode placeholder text color problem

On native textfields and boxes the color of placeholders are hardcoded in corona core:

[super setText:\_placeholder]; [self setTextColor:[UIColor lightGrayColor]]; \_showingPlaceholder = true;

In my app I use black text on white backgrounds, so when switching to dark mode the placeholders can’t be seen because the text color is the same as the background color. (I do not intend to create a full dark mode version of the app)

Please fix it. Thanks.

Consider making a pull request with a suggested fix.  I’ll ask engineering, but I can’t confirm when we can get to it.

Rob

I can do a pull request for iOS with a new textField:setPlaceholderTextColor() call but I suspect you would want this to work on all supported platforms?

Would you accept a pull with stubs for the other platforms?

I was thinking on fixing the issue tomorrow. Probably I will make that default colors are different when in dark mode.

If it won’t work out very well, I’ll add setPlaceholderTextColor.

Great thanks vlads.

You might wan’t to look into the default text color for the textfields too.

If text color is not set with setTextColor then it uses a system color that are also changed when iOS is in dark mode.

This can result in text being “invisible” because it has the same color as the background.

I just discovered that it is possible to add this to the plist settings in the build.settings:

UIUserInterfaceStyle = "light",

This forces the app to use light mode.

If we rebuild our apps with that everything will work as before.

Maybe you should do a blog post warning about this, because dark mode messes with app builds already in the store.

Thanks. This is great idea!

I also ‘fixed’ dark mode edit boxes, and added way to detect dark mode. Should be up in next release.

FYI, iTunes Connect will reject “light” as a key for UIUserInterfaceStyle.  It must be “Light”.  Apparently casing matters.

Hey guys. So new build just went up. Please, feel freeto test. It contains both system.getInfo(‘darkMode’) and better defaults for color of text box.

https://developer.coronalabs.com/release/2019/3544/

Please make this work on Mac OS as well.

https://developer.coronalabs.com/release/2019/3545/ should have macOS working as well.

It seems the new Dark Mode setting
UIUserInterfaceStyle = "Light",
does not work on Mac OS (in macos.plist in build.settings)

Oh. Sorry, that is what you mean. Yes, UIUserInterfaceStyle is iOS only. UIKit is unavailable on macOS.
Mac OS entry should be NSRequiresAquaSystemAppearance = true
This will force app to light mode (aka “aqua” on macOS)

Thanks vlads!

I’ve updated the blog post to clarify the plist settings.

Rob