如何在IQKeyboardManager iOS Swift 3中隐藏工具栏 [英] How to hide Toolbar in IQKeyboardManager iOS Swift 3
问题描述
我开始使用 IQKeyboardManger 库在开始使用键盘键入内容时滚动文本字段,但是我不想显示其库中的默认工具栏.下面是我使用的代码.
I'm using the IQKeyboardManger library to scroll text fields when started typing using the keyboard, but I don't want to display the default toolbar from their library. Below is the code I've used.
override func viewDidLoad() {
super.viewDidLoad()
self.chatTextField.inputAccessoryView = [[UIView alloc] init]; //This will remove toolbar which have done button.
self.chatTextField.keyboardDistanceFromTextField = 8; //This will modify default distance between textField and keyboard. For exact value, please manually check how far your textField from the bottom of the page. Mine was 8pt.
}
推荐答案
您可以在属性下方设置IQKeyboardManager.
You can set IQKeyboardManager below properties.
我假设您已经在像这样的应用程序委托的didFinishLaunch中启用了IQKeyboardManager
I assume you have enabled the IQKeyboardManager in didFinishLaunch of app delegate like this
IQKeyboardManager.sharedManager().enable = true
shouldShowTextFieldPlaceholder 到false
==>如果要隐藏占位符工具栏部分
shouldShowTextFieldPlaceholder to false
==> If you want to hide placeholder toolbar section
应该将PreviousHidePreviousNext 隐藏到false
==>如果要隐藏下一步"和上一步"按钮等.
shouldHidePreviousNext to false
==> If you want to hide next and prev button and so on.
您可以像这样在 AppDelegate 的 didFinishLaunch 中启用设置
You can enable the settings in didFinishLaunch of AppDelegate like this
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
IQKeyboardManager.sharedManager().enable = true
IQKeyboardManager.sharedManager().enableAutoToolbar = false
IQKeyboardManager.sharedManager().shouldShowTextFieldPlaceholder = false
IQKeyboardManager.sharedManager().shouldHidePreviousNext = false
return true
}
这篇关于如何在IQKeyboardManager iOS Swift 3中隐藏工具栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!