iOS utility class allows you to access keyboard view and track keyboard animation.

Overview

YYKeyboardManager

License MIT  Carthage compatible  CocoaPods  CocoaPods  Support  Build Status

iOS utility class allows you to access keyboard view and track keyboard animation.
(It was used by YYText)

demo

Compatibility

iPhone / iPad / iPod with iOS 6~11.

Usage

// Get keyboard manager
YYKeyboardManager *manager = [YYKeyboardManager defaultManager];
	
// Get keyboard view and window
UIView *view = manager.keyboardView;
UIWindow *window = manager.keyboardWindow;
	
// Get keyboard status
BOOL visible = manager.keyboardVisible;
CGRect frame = manager.keyboardFrame;
frame = [manager convertRect:frame toView:self.view];
	
// Track keyboard animation
[manager addObserver:self];
- (void)keyboardChangedWithTransition:(YYKeyboardTransition)transition {
    CGRect fromFrame = [manager convertRect:transition.fromFrame toView:self.view];
    CGRect toFrame =  [manager convertRect:transition.toFrame toView:self.view];
    BOOL fromVisible = transition.fromVisible;
    BOOL toVisible = transition.toVisible;
    NSTimeInterval animationDuration = transition.animationDuration;
    UIViewAnimationCurve curve = transition.animationCurve;
}

Installation

CocoaPods

  1. Add pod 'YYKeyboardManager' to your Podfile.
  2. Run pod install or pod update.
  3. Import <YYKeyboardManager/YYKeyboardManager.h>.

Carthage

  1. Add github "ibireme/YYKeyboardManager" to your Cartfile.
  2. Run carthage update --platform ios and add the framework to your project.
  3. Import <YYKeyboardManager/YYKeyboardManager.h>.

Manually

  1. Download all the files in the YYKeyboardManager subdirectory.
  2. Add the source files to your Xcode project.
  3. Import YYKeyboardManager.h.

Documentation

Full API documentation is available on CocoaDocs.
You can also install documentation locally using appledoc.

Requirements

This library requires iOS 6.0+ and Xcode 8.0+.

License

YYKeyboardManager is provided under the MIT license. See LICENSE file for details.



中文介绍

iOS 键盘监听管理工具类。
(该工具是从 YYText 提取出来的独立组件)

demo

兼容性

该项目能很好的兼容 iPhone / iPad / iPod,兼容 iOS 6~11, 并且能很好的处理屏幕旋转。

用法

// 获取键盘管理器
YYKeyboardManager *manager = [YYKeyboardManager defaultManager];
	
// 获取键盘的 view 和 window
UIView *view = manager.keyboardView;
UIWindow *window = manager.keyboardWindow;
	
// 获取键盘当前状态
BOOL visible = manager.keyboardVisible;
CGRect frame = manager.keyboardFrame;
frame = [manager convertRect:frame toView:self.view];
	
// 监听键盘动画
[manager addObserver:self];
- (void)keyboardChangedWithTransition:(YYKeyboardTransition)transition {
    CGRect fromFrame = [manager convertRect:transition.fromFrame toView:self.view];
    CGRect toFrame =  [manager convertRect:transition.toFrame toView:self.view];
    BOOL fromVisible = transition.fromVisible;
    BOOL toVisible = transition.toVisible;
    NSTimeInterval animationDuration = transition.animationDuration;
    UIViewAnimationCurve curve = transition.animationCurve;
}

安装

CocoaPods

  1. 在 Podfile 中添加 pod 'YYKeyboardManager'
  2. 执行 pod installpod update
  3. 导入 <YYKeyboardManager/YYKeyboardManager.h>。

Carthage

  1. 在 Cartfile 中添加 github "ibireme/YYKeyboardManager"
  2. 执行 carthage update --platform ios 并将生成的 framework 添加到你的工程。
  3. 导入 <YYKeyboardManager/YYKeyboardManager.h>。

手动安装

  1. 下载 YYKeyboardManager 文件夹内的所有内容。
  2. 将 YYKeyboardManager 内的源文件添加(拖放)到你的工程。
  3. 导入 YYKeyboardManager.h

文档

你可以在 CocoaDocs 查看在线 API 文档,也可以用 appledoc 本地生成文档。

系统要求

该项目最低支持 iOS 6.0Xcode 8.0

许可证

YYKeyboardManager 使用 MIT 许可证,详情见 LICENSE 文件。

You might also like...
Objective-C library for tracking keyboard in iOS apps.
Objective-C library for tracking keyboard in iOS apps.

NgKeyboardTracker Objective-c library for tracking keyboard in iOS apps. Adding to your project If you are using CocoaPods, add to your Podfile: pod '

A drop-in universal solution for moving text fields out of the way of the keyboard in iOS

TPKeyboardAvoiding A drop-in universal solution for moving text fields out of the way of the keyboard in iOS. Introduction There are a hundred and one

Emoji Keyboard SDK (iOS)
Emoji Keyboard SDK (iOS)

Makemoji SDK Makemoji is a free emoji keyboard for mobile apps. By installing our keyboard SDK every user of your app will instantly have access to ne

A Chinese keyboard for iOS that helps Chinese language learners remember tones.
A Chinese keyboard for iOS that helps Chinese language learners remember tones.

ToneBoard ToneBoard is a Chinese keyboard for iOS that requires you to enter the correct tones while typing simplified Chinese with Pinyin. It is avai

SwiftyKeyboard: a full customized numeric keyboard for iOS
SwiftyKeyboard: a full customized numeric keyboard for iOS

SwiftyKeyboard Overview SwiftyKeyboard is an iOS customized enhanced keyboard. T

Slidden is an open source, customizable, iOS 8 keyboard, written in Swift
Slidden is an open source, customizable, iOS 8 keyboard, written in Swift

Slidden is an open source, customizable, iOS 8 keyboard, written in Swift. iOS 8 brought us the ability to create fully customizable keyboards, but do

Emoji Keyboard for iOS
Emoji Keyboard for iOS

English | 中文 An easy to use Emoji keyboard for iOS. Has been rewritten with swift, the old Objective-C version on branch oc. Features Written in Swift

IHKeyboardAvoiding is an elegant solution for keeping any UIView visible when the keyboard is being shown - no UIScrollView required!
IHKeyboardAvoiding is an elegant solution for keeping any UIView visible when the keyboard is being shown - no UIScrollView required!

IHKeyboardAvoiding An elegant solution for keeping any UIView visible when the keyboard is being shown Requirements IHKeyboardAvoiding Version Objecti

⌨️ Add user-customizable global keyboard shortcuts to your macOS app in minutes
⌨️ Add user-customizable global keyboard shortcuts to your macOS app in minutes

This package lets you add support for user-customizable global keyboard shortcuts to your macOS app in minutes. It's fully sandbox and Mac App Store c

Comments
  • 对这个判断有点疑问

    对这个判断有点疑问

    你好,看源码时,对_getKeyboardViewFromWindow:方法的判断有点疑问:

    // UITextEffectsWindow
    if (windowName.length != 19) return nil;
    if (![windowName hasPrefix:@"UI"]) return nil;
    if (![windowName hasSuffix:@"TextEffectsWindow"]) return nil;
    

    为何不用: if (![windowName isEqualToString:@"UITextEffectsWindow"]) return nil;

    这两种判断有什么区别吗?

    opened by ColinHwang 2
  • demoFix: demo中的动画用的参数Duration

    demoFix: demo中的动画用的参数Duration

    Demo里面的动画 [UIView animateWithDuration:transition.animationCurve delay:0 options:transition.animationOption 用的是transition.animationCurve,是不是输入错误?应该是用的transition.animationDuration的么? 虽然显示上是没什么问题的。请问为什么会没问题呢?Debug的时候,transition.animationCurve 的值是7。transition.animationCurves 是0.25。

    opened by XVXVXXX 1
  • iOS8.1.3下可能会出现userInfo中UIKeyboardFrame前后一样的情况

    iOS8.1.3下可能会出现userInfo中UIKeyboardFrame前后一样的情况

    在iPhone 5s iOS8.1.3系统版本下UIKeyboardWillChangeFrameNotification通知中有时候获取userInfo后UIKeyboardFrameBeginUserInfoKey&UIKeyboardFrameEndUserInfoKey,UIKeyboardCenterBeginUserInfoKey&UIKeyboardCenterEndUserInfoKey前后一样的情况, 会导致keyboardChangedWithTransition执行不到的问题。 ios8 1 3

    opened by yhb329 0
Owner
null
Codeless drop-in universal library allows to prevent issues of keyboard sliding up and cover UITextField/UITextView. Neither need to write any code nor any setup required and much more.

IQKeyboardManager While developing iOS apps, we often run into issues where the iPhone keyboard slides up and covers the UITextField/UITextView. IQKey

Mohd Iftekhar Qurashi 15.9k Jan 8, 2023
Showing / dismissing keyboard animation in simple UIViewController category.

RSKKeyboardAnimationObserver Easy way to handle iOS keyboard showing/dismissing. Introduction Working with iOS keyboard demands a lot of duplicated co

Ruslan Skorb 45 Jun 9, 2022
KeyboardKit is a Swift library that helps you create custom keyboard extensions for iOS and ipadOS.

KeyboardKit is a Swift library that helps you create custom keyboard extensions for iOS and ipadOS.

KeyboardKit 900 Jan 9, 2023
Best way to dismiss Keyboard in a View Controller iOS (Swift)

Best way to dismiss Keyboard in a View Controller iOS (Swift) First way: Implement UITextFieldDelegate’s textFieldShouldReturn method and dismiss curr

null 0 Dec 18, 2021
HomeWork3.2 - How to work with sliders, textfield, keyboard, view

HomeWork3.2 How to work with sliders, textfield, keyboard, view

Artur 1 Jan 26, 2022
A simple keyboard to use with numbers and, optionally, a decimal point.

MMNumberKeyboard A simple keyboard to use with numbers and, optionally, a decimal point. Installation From CocoaPods CocoaPods is a dependency manager

Matías Martínez 957 Nov 17, 2022
⌨️A Combine-based way to observe and adjust for Keyboard notifications in SwiftUI

⌨️ Keyboard Observing A Combine-based solution for observing and avoiding the keyboard in SwiftUI. Table of Contents About Requirements Installation C

Nick Fox 440 Jan 5, 2023
Prevent keyboard from covering UITextField/UITextView, includes Swift and Objective-C APIs

Prevent keyboard from covering UITextField/UITextView with only one line of code, includes Swift and Objective-C APIs.

LiuChang 8 Oct 24, 2022
Codeless manager to hide keyboard by tapping on views for iOS written in Swift

KeyboardHideManager KeyboardHideManager - codeless manager to hide keyboard by tapping on views for iOS written in Swift. Structure Features Requireme

Bondar Yaroslav 55 Oct 19, 2022
Swift UIKit keyboard manager for iOS apps.

Typist Typist is a small, drop-in Swift UIKit keyboard manager for iOS apps. It helps you manage keyboard's screen presence and behavior without notif

Toto Tvalavadze 1.1k Dec 10, 2022