Skip to content

XiFengLang/JKKeyboardObserver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

version platform ios

JKKeyboardManager

全局监听键盘弹出事件,自动处理键盘遮盖问题,动态调整输入框和键盘的相对位置。

Usage

  • application didFinishLaunchingWithOptions 中初始化并设置全局属性

    KeyboardManager().robotizationEnable = YES;
    // 设置键盘到输入框的距离
    KeyboardManager().topSpacingToFirstResponder = 20;
    // 显示自定义的toolBar,切换输入框或者隐藏键盘
    KeyboardManager().showExtensionToolBar = YES;
    
    // 内联函数,返回单例
	static inline JKKeyboardManager * KeyboardManager() {
	    return [JKKeyboardManager sharedKeyboardManager];
	}
  • 为特定类定制属性,比如键盘到输入框的距离
	[KeyboardManager() setTopSpacingToFirstResponder:30 forViewControllerClass:self.class];

其他

  • 隐藏键盘(全局效果)
   [KeyboardManager() hideKeyboard];
  • 取当前显示的window
	KeyboardManager().keyWindow
  • 取最上层的控制器(当前显示的控制器)
	KeyboardManager().currentViewController

gif

Releases

No releases published

Packages

No packages published