Overview
Version 6.0 brings refined API naming, new customization options, and improved view hierarchy handling. The changes are relatively minimal compared to later versions, making this one of the smoother migrations.
This migration primarily involves updating a few method names and optionally adopting new features.
Breaking Changes
IQKeyboardManager Shared Instance
The class method for accessing the shared instance has been simplified:
v5 Shared Instance
v6 Shared Instance
let manager = IQKeyboardManager. sharedManager ()
Both sharedManager() and shared may work in v6 due to backwards compatibility, but shared is the preferred API going forward.
UIView Extension Method Rename
The method to get a view’s containing view controller has been renamed for clarity:
v5 View Controller
v6 View Controller
let controller = view. viewController ()
New Features in v6
Version 6.0 introduces several new customization options:
Placeholder Color Customization
You can now customize the color of toolbar placeholders:
import IQKeyboardManagerSwift
func application ( _ application : UIApplication, didFinishLaunchingWithOptions launchOptions : [UIApplication.LaunchOptionsKey: Any ] ? ) -> Bool {
IQKeyboardManager. shared . enable = true
// New in v6: Customize placeholder colors
IQKeyboardManager. shared . placeholderColor = . gray
IQKeyboardManager. shared . placeholderButtonColor = . systemBlue
return true
}
Additional Safe Area Insets
Experimental Feature : This feature was marked as experimental in v6 and was removed in v7.
// Available in v6 only (removed in v7)
IQKeyboardManager. shared . canAdjustAdditionalSafeAreaInsets = true
UIView Customization Properties
Ignore Next/Previous Switching
Control whether specific text fields participate in the Previous/Next navigation:
// New in v6
textField. ignoreSwitchingByNextPrevious = true
Resign on Touch Outside Mode
Fine-grained control over dismiss-on-tap behavior per text field:
// New in v6
textField. shouldResignOnTouchOutsideMode = . enabled // Always resign
textField. shouldResignOnTouchOutsideMode = . disabled // Never resign
textField. shouldResignOnTouchOutsideMode = . default // Use global setting
Parent Container View Controller
New helper method to get the parent container view controller:
// New in v6
if let container = textField. parentContainerViewController () {
print ( "Container: \( container ) " )
}
Migration Steps
Update Dependency
Update your Podfile or Package.swift to version 6.0+ # CocoaPods
pod 'IQKeyboardManagerSwift' , '~> 6.0'
// Swift Package Manager
. package ( url : "https://github.com/hackiftekhar/IQKeyboardManager.git" , from : "6.0.0" )
Install Dependencies
# CocoaPods
pod install
# Swift Package Manager
# File > Packages > Update to Latest Package Versions
Update Shared Instance Access
Replace sharedManager() with shared: // Before
IQKeyboardManager. sharedManager (). enable = true
// After
IQKeyboardManager. shared . enable = true
Use find-and-replace to update all instances:
Find: IQKeyboardManager.sharedManager()
Replace: IQKeyboardManager.shared
Update View Controller Method
Replace viewController() with viewContainingController(): // Before
let controller = view. viewController ()
// After
let controller = view. viewContainingController ()
Build and Test
Build your project
Test keyboard behavior
Verify no deprecation warnings appear
Adopt New Features (Optional)
Consider using new v6 features: // Customize placeholder appearance
IQKeyboardManager. shared . placeholderColor = . secondaryLabel
IQKeyboardManager. shared . placeholderButtonColor = . systemBlue
// Fine-tune specific text fields
passwordTextField. ignoreSwitchingByNextPrevious = true
searchField. shouldResignOnTouchOutsideMode = . enabled
Complete Migration Example
import IQKeyboardManagerSwift
class AppDelegate : UIResponder , UIApplicationDelegate {
func application ( _ application : UIApplication, didFinishLaunchingWithOptions launchOptions : [UIApplication.LaunchOptionsKey: Any ] ? ) -> Bool {
// Configure keyboard manager
let manager = IQKeyboardManager. sharedManager ()
manager. enable = true
manager. enableAutoToolbar = true
manager. shouldResignOnTouchOutside = true
return true
}
}
class MyViewController : UIViewController {
@IBOutlet weak var myView: UIView !
func findViewController () {
if let controller = myView. viewController () {
print ( "Found: \( controller ) " )
}
}
}
Per-Field Customization Example
One of the powerful new features in v6 is per-field customization:
class LoginViewController : UIViewController {
@IBOutlet weak var emailTextField: UITextField !
@IBOutlet weak var passwordTextField: UITextField !
@IBOutlet weak var confirmPasswordTextField: UITextField !
override func viewDidLoad () {
super . viewDidLoad ()
// Password field shouldn't be navigable via Previous/Next
passwordTextField. ignoreSwitchingByNextPrevious = true
confirmPasswordTextField. ignoreSwitchingByNextPrevious = true
// Email field always dismisses keyboard when tapping outside,
// even if global setting is disabled
emailTextField. shouldResignOnTouchOutsideMode = . enabled
}
}
Benefits of v6
Cleaner API Simplified shared instance access with shared property
Better Naming More descriptive method names like viewContainingController()
Enhanced Customization New placeholder color options for better theming
Granular Control Per-field customization options for complex forms
Troubleshooting
'sharedManager()' is deprecated
Solution : Replace with shared:// Old
IQKeyboardManager. sharedManager ()
// New
IQKeyboardManager. shared
'viewController()' method not found
Solution : Use viewContainingController() instead:// Old
view. viewController ()
// New
view. viewContainingController ()
Placeholder colors not changing
Check : Ensure you have shouldShowToolbarPlaceholder enabled:IQKeyboardManager. shared . shouldShowToolbarPlaceholder = true
IQKeyboardManager. shared . placeholderColor = . gray
Deprecation Warnings
If you see deprecation warnings in v6, they’re likely for features that will be removed in v7:
Features marked as deprecated in v6:
canAdjustAdditionalSafeAreaInsets (removed in v7)
preventShowingBottomBlankSpace (removed in v7)
shouldFixInteractivePopGestureRecognizer (removed in v7)
If you’re using these features, consider alternatives before upgrading to v7.
Compatibility Notes
iOS Version Support
Version 6.0 dropped support for older iOS versions. Ensure your deployment target meets the minimum requirement:
# Podfile
platform :ios , '13.0' # Check the exact minimum in release notes
Swift Version
Version 6.0 requires Swift 5.0 or later. Ensure your project uses a compatible Swift version.
Next Steps
After successfully migrating to v6:
Explore New Features
Try out the new customization options like placeholderColor and placeholderButtonColor
Refine Per-Field Behavior
Use ignoreSwitchingByNextPrevious and shouldResignOnTouchOutsideMode for better UX
Need Help?
If you encounter issues:
Check GitHub Issues
Review the v6 release notes
Ask in Stack Overflow with the iqkeyboardmanager tag
Simple Migration : The v5 to v6 migration is one of the simplest in IQKeyboardManager’s history. Most apps can complete it in under 30 minutes.