Overview
The Appearance subspec allows you to override the keyboard appearance globally or per-view, making it easy to maintain a consistent look across your app.Installation
The Appearance subspec is included by default when you install IQKeyboardManagerSwift:Podfile
Configuration Object
Appearance settings are managed through theIQKeyboardAppearanceConfiguration object:
AppDelegate.swift
Global Appearance Override
Set a consistent keyboard appearance for all text fields in your app:AppDelegate.swift
Appearance Options
The keyboard supports three appearance modes:Uses the system default appearance (light on iOS)
Light keyboard with dark text
Dark keyboard with light text
Examples
Force Dark Keyboard
AppDelegate.swift
Force Light Keyboard
AppDelegate.swift
Use System Default
AppDelegate.swift
Per-View Appearance
While the global configuration affects all text fields, individual text fields can still set their own keyboard appearance when override is disabled:ViewController.swift
Dynamic Appearance Changes
You can change the keyboard appearance at runtime:ViewController.swift
Dark Mode Support
To automatically match system dark mode:AppDelegate.swift
Respond to Dark Mode Changes
ViewController.swift
Complete Example
Here’s a complete example with theme switching:ThemeManager.swift
SettingsViewController.swift
Configuration Properties
When
true, applies the configured appearance to all text input views, ignoring individual keyboardAppearance settings.The keyboard appearance to use when
overrideAppearance is true. Options: .default, .light, .dark.When Override is Disabled
WhenoverrideAppearance is false:
- Each text field uses its own
keyboardAppearanceproperty - UITextField and UITextView default to
.default - You can set different appearances for different fields
- System respects individual field settings
ViewController.swift
Best Practices
Match your app's theme
Match your app's theme
Set the keyboard appearance to match your app’s overall theme for a cohesive user experience.
Consider accessibility
Consider accessibility
Some users may find dark keyboards easier to read in low-light conditions, while others prefer light keyboards.
Test both appearances
Test both appearances
Always test your forms with both light and dark keyboard appearances to ensure text visibility.
Reload keyboard after changes
Reload keyboard after changes
Call
reloadInputViews() on active text fields after changing appearance settings to see changes immediately.Troubleshooting
Appearance not changing
Appearance not changing
- Verify
overrideAppearanceis set totrue - Call
reloadInputViews()on the active text field - Check if a custom
inputViewis overriding the keyboard
Individual field settings ignored
Individual field settings ignored
This is expected when
overrideAppearance is true. Set it to false to respect individual field settings.Dark mode not syncing
Dark mode not syncing
Implement
traitCollectionDidChange(_:) in your view controller to respond to system appearance changes.Next Steps
Advanced Configuration
Customize keyboard distance and behavior
Toolbar Management
Add Previous/Next/Done buttons
Resign Keyboard
Dismiss keyboard on tap outside
API Reference
Full appearance API documentation