Skip to main content

Overview

IQKeyboardAppearanceConfiguration is a configuration class that manages keyboard appearance settings for text input views throughout your application. It allows you to override and standardize the keyboard appearance across all text fields and text views.
This class is marked with @MainActor, so all property access must occur on the main thread.

Class Declaration

@available(iOSApplicationExtension, unavailable)
@MainActor
@objcMembers public final class IQKeyboardAppearanceConfiguration: NSObject

Properties

overrideAppearance
Bool
default:"false"
Determines whether to override the keyboard appearance for all text input views. When set to true, all text input views will use the appearance specified in the appearance property.
configuration.overrideAppearance = true
appearance
UIKeyboardAppearance
default:".default"
The keyboard appearance to apply to all text input views when overrideAppearance is enabled. This property accepts any value from the UIKeyboardAppearance enum.
configuration.appearance = .dark

UIKeyboardAppearance Values

The appearance property accepts the following UIKeyboardAppearance enum values:
ValueDescription
.defaultThe default keyboard appearance for the current input trait settings
.darkA keyboard appearance suitable for a dark UI
.lightA keyboard appearance suitable for a light UI
.alertDeprecated. Use .light instead

Usage Examples

Basic Configuration

let configuration = IQKeyboardAppearanceConfiguration()
configuration.overrideAppearance = true
configuration.appearance = .dark

Integration with IQKeyboardManager

// Access through IQKeyboardManager
IQKeyboardManager.shared.keyboardConfiguration.overrideAppearance = true
IQKeyboardManager.shared.keyboardConfiguration.appearance = .dark

Conditional Appearance Based on Dark Mode

if traitCollection.userInterfaceStyle == .dark {
    IQKeyboardManager.shared.keyboardConfiguration.appearance = .dark
} else {
    IQKeyboardManager.shared.keyboardConfiguration.appearance = .light
}
IQKeyboardManager.shared.keyboardConfiguration.overrideAppearance = true

Disabling Override

// Allow each text field to use its own keyboard appearance
IQKeyboardManager.shared.keyboardConfiguration.overrideAppearance = false

Important Notes

The appearance is only applied when a text input view begins editing. Changing these properties while a keyboard is already visible will not take effect until the next text input view becomes active.
This class is unavailable in iOS App Extensions due to its dependency on UIApplication features.

See Also

Build docs developers (and LLMs) love