My app has a dark overall theme. On iOS, I’d like the textfields to use the iOS dark keyboard. Is this possible?
One easy way without runtime code is to declare your app as dark appearance by adding key “UIUserInterfaceStyle” to the Info.plist and set the value to “Dark”.
Do note that this only works on iOS 13 or later. It has no effect on older OS.
Edit: Some extra reading from the forum if you are using TextMeshPro (which is universally recommended over UGUI’s text). Basically you want to take control of the keyboard appearance and show it as an alert keyboard which on iOS is equivalent to dark appearance.
Neonlyte,
Thanks for the response. I’m an iOS developer and am familiar with the Info.plist. However, I thought that was automatically generated when you built the iOS version. Any manual change you made to it would get overridden, right? I didn’t see anything in the Unity UI that allows you to add arbitrary keys in the Info.plist.
As for the other suggestions, I can try showing it as an alert keyboard using TextMeshPro. Didn’t know that made it dark. Your links give me other ideas to try as well.
My experience is that the Info.plist gets overridden only if choosing “Replace”.
But there are post build processing API to automate modifying the Info.plist should you need it:
#if UNITY_IOS
using UnityEditor;
using UnityEngine;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using System.IO;
public class K4iOSPostProcessing_InfoPlistModifcation
{
[PostProcessBuild]
public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
{
// Get plist
string plistPath = pathToBuiltProject + "/Info.plist";
PlistDocument plist = new PlistDocument();
plist.ReadFromString(File.ReadAllText(plistPath));
// Get root
PlistElementDict rootDict = plist.root;
#if ENABLE_FILE_SHARING
rootDict.SetBoolean("UIFileSharingEnabled", true);
rootDict.SetBoolean("LSSupportsOpeningDocumentsInPlace", true);
#endif
rootDict.SetBoolean("ITSAppUsesNonExemptEncryption", false);
// rootDict.SetBoolean("CADisableMinimumFrameDuration", true);
// Write to file
File.WriteAllText(plistPath, plist.WriteToString());
}
}
#endif