KeyboardMan helps you to make keyboard animation.

Related tags

Keyboard KeyboardMan
Overview

KeyboardMan

We may need keyboard infomation from keyboard notifications to do animation. However, the approach is complicated and easy to make mistakes. Even more, we need to handle the bug of system fire keyboard notifications.

But KeyboardMan will make it simple & easy.

另有中文介绍

Requirements

Swift 4.2, iOS 8.0

(Swift 3, use version 1.1.0)

Example

import KeyboardMan

Do animation with keyboard appear/disappear:

let keyboardMan = KeyboardMan()

keyboardMan.animateWhenKeyboardAppear = { [weak self] appearPostIndex, keyboardHeight, keyboardHeightIncrement in

    print("appear \(appearPostIndex), \(keyboardHeight), \(keyboardHeightIncrement)\n")

    if let self = self {

        self.tableView.contentOffset.y += keyboardHeightIncrement
        self.tableView.contentInset.bottom = keyboardHeight + self.toolBar.frame.height

        self.toolBarBottomConstraint.constant = keyboardHeight
        self.view.layoutIfNeeded()
    }
}

keyboardMan.animateWhenKeyboardDisappear = { [weak self] keyboardHeight in

    print("disappear \(keyboardHeight)\n")

    if let self = self {

        self.tableView.contentOffset.y -= keyboardHeight
        self.tableView.contentInset.bottom = self.toolBar.frame.height

        self.toolBarBottomConstraint.constant = 0
        self.view.layoutIfNeeded()
    }
}

For more specific information, you can use keyboardInfo that KeyboardMan post:

keyboardMan.postKeyboardInfo = { [weak self] keyboardMan, keyboardInfo in
    // TODO
}

Check the demo for more information.

Installation

Feel free to drag KeyboardMan.swift to your iOS Project. But it's recommended to use Carthage (or CocoaPods).

Carthage

github "nixzhu/KeyboardMan"

CocoaPods

pod 'KeyboardMan'

Contact

NIX @nixzhu

License

KeyboardMan is available under the MIT license. See the LICENSE file for more info.

Comments
  • redefine `keyboardInfo` property observer

    redefine `keyboardInfo` property observer

    In some case, I want to use keyboardInfo to animate some views in animateWhenKeyboardAppear.

    keyboardMan.animateWhenKeyboardAppear = { [weak self] appearPostIndex, keyboardHeight, keyboardHeightIncrement in
            // self?.animateViews()
    }
    
    opened by Limon-O-O 3
  • Support for using KeyboardMan in app extension

    Support for using KeyboardMan in app extension

    In app extension targets, the UIApplication.shared is not available.

    This p-r supplies a workaround for it to use KeyboardMan in both app target and extension target.

    Both MailMe app and Kingfisher is using this strategy so I think that it is proved to be AppStore-safe too.

    opened by onevcat 1
  • Add Callbacks keyboardWillShow, keyboardDidShow, keyboardWillHide and keyboardDidHide.

    Add Callbacks keyboardWillShow, keyboardDidShow, keyboardWillHide and keyboardDidHide.

    Hi, First of all, I think this project is great idea, I am currently using it in a messaging app.

    However, I thought that there were a few things missing. How do you perform an action before the keyboard shows or after it shows ? Same for when the keyboard hides.

    That's why I added these easy callbacks. I also swapped an 'if' with a 'guard else' while I was at it.

    I hope you like it.

    opened by CallumOz 1
  • Expand property `keyboardInfo` scope

    Expand property `keyboardInfo` scope

    In some case, I want to use keyboardInfo.animationDuration or keyboardInfo.animationCurve to shrink my messageToolBar.

    public var postKeyboardInfo: ((keyboardMan: KeyboardMan, keyboardInfo: KeyboardInfo) -> Void)?

    This property also can get the keyboardInfo, but sometime I need shrink my messageToolBar when keyboard is not appearing.

    opened by Limon-O-O 0
  • something wrong with  animation  when keyboard resignFirstResponder

    something wrong with animation when keyboard resignFirstResponder

    In ViewController.swift File , implement UIScrollViewDelegate‘s method scrollViewWillBeginDragging. like below:

     func scrollViewWillBeginDragging(scrollView: UIScrollView) {
    
            self.textField.resignFirstResponder();
    }
    

    the animation of toolBar is faster than keyboard's

    keyboardman

    opened by jiehu5114 0
  • IOS10用第三方输入法的问题

    IOS10用第三方输入法的问题

    IOS10上第三方输入法会闪一下,导致view改变位置的动画出现问题~ IOS10的第三方输入法框高度不是递增或递减的,从其他输入法切换到第三方输入法时会多调用一次键盘的监听方法

    IOS9: appear 9, 0.0, -216.0

    appear 10, 216.0, 216.0

    appear 11, 282.0, 66.0

    IOS10: appear 4, 282.0, 66.0

    appear 5, 216.0, -66.0

    appear 6, 282.0, 66.0

    作者有解决方法么?

    opened by yn288163 1
Owner
null
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
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

Kevin Bell 7 Sep 27, 2022
SwiftUIKeyPress - a package to make up for the lack of keyboard input in SwiftUI

SwiftUIKeyPress - a package to make up for the lack of keyboard input in SwiftUI

Underthestars-zhy 8 Oct 27, 2022
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
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

Idle Hands Apps 1.4k Dec 14, 2022
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
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
⌨️ 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

Sindre Sorhus 1.1k Dec 29, 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
Suppress mouse & keyboard events on MacOSX. Baby-proof my Mac!

Suppress mouse & keyboard events on MacOSX Catches all events (mouse, keyboard, everything), and either consumes them (locked state) or passes them th

Albert Zeyer 6 Oct 21, 2022
QMK Agent is a macOS menubar application which sends commands to a QMK enabled keyboard

QMKagent QMK Agent is a macOS menubar application which sends commands to a QMK enabled keyboard Features System volume indicator using top row (Esc t

Mike Killewald 4 Apr 24, 2022
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
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 '

Meiwin Fu 808 Nov 17, 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
For less complicated keyboard event handling.

KeyboardObserver For less complicated keyboard event handling. Features Less complicated keyboard event handling. Do not use Notification , but event

Morita Naoki 163 May 24, 2022
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

Michael Tyson 5.8k Dec 26, 2022
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

Makemoji 100 Nov 3, 2022
SwiftyKeyboard: a full customized numeric keyboard for iOS

SwiftyKeyboard Overview SwiftyKeyboard is an iOS customized enhanced keyboard. T

SwiftyKit 2 Jun 30, 2022
Interactive Keyboard Controller for Swift

Keynode Why Using UIScrollViewKeyboardDismissMode added in iOS7, interactive keyboard operation became possible. But, it only works on UIScrollView. K

Kyohei Ito 76 Sep 1, 2020