为什么我的键盘在深色模式下采用这种背景颜色?

Why my keyboard take this background color on Dark mode?

This is my keyboard on dark mode

我正在使用这个:

field.KeyboardAppearance = UIKeyboardAppearance.Dark;

更新: 您必须设置背景视图

view.backgroundColor = .black //(for dark mode)

view.backgroundColor = .white //(for light mode)

Xamarin.iOS

View.BackgroundColor = UIColor.Black; //(for dark mode)

View.BackgroundColor = UIColor.White; //(for light mode)

欢迎来到 SO!

Apple设计UIKeyboardAppearance有四种类型,每种类型都有其特点。

  • UIKeyboardAppearanceDefault :指定当前输入法的默认键盘外观。该常数对应于 UIKeyboardAppearanceLight 价值.

  • UIKeyboardAppearanceDark : 指定适合深色 UI 外观的键盘外观。

  • UIKeyboardAppearanceLight : 指定适合浅色 UI 外观的键盘外观。

  • UIKeyboardAppearanceAlert : 指定适合警报面板的键盘外观。

因此,设置时键盘会显示深色背景

field.KeyboardAppearance = UIKeyboardAppearance.Dark;

我在评论中看到了你的图片,我注意到为什么你的键盘看起来比 WhatsApp 键盘更 "whiter"。这是因为 WhatsApp 背景是黑色的,而我们的 iOS 键盘是半透明的。

尝试将背景设置为黑色

view.backgroundColor = .black

看看会发生什么!希望对你有帮助