Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nixzhu/KeyboardMan
KeyboardMan helps you to make keyboard animation.
https://github.com/nixzhu/KeyboardMan
Last synced: 3 months ago
JSON representation
KeyboardMan helps you to make keyboard animation.
- Host: GitHub
- URL: https://github.com/nixzhu/KeyboardMan
- Owner: nixzhu
- License: mit
- Created: 2015-07-25T18:32:08.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-09-16T03:07:45.000Z (about 6 years ago)
- Last Synced: 2024-04-24T14:49:32.746Z (6 months ago)
- Language: Swift
- Homepage:
- Size: 69.3 KB
- Stars: 351
- Watchers: 11
- Forks: 30
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - KeyboardMan - KeyboardMan helps you make keyboard animation. (UI / Keyboard)
- awesome-ios-star - KeyboardMan - KeyboardMan helps you make keyboard animation. (UI / Keyboard)
README
# 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.
另有[中文介绍](https://github.com/nixzhu/dev-blog/blob/master/2015-07-27-keyboard-man.md)。
## Requirements
Swift 4.2, iOS 8.0
(Swift 3, use version 1.1.0)
## Example
```swift
import KeyboardMan
```Do animation with keyboard appear/disappear:
```swift
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.heightself.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.heightself.toolBarBottomConstraint.constant = 0
self.view.layoutIfNeeded()
}
}
```For more specific information, you can use keyboardInfo that KeyboardMan post:
```swift
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
```ogdl
github "nixzhu/KeyboardMan"
```### CocoaPods
```ruby
pod 'KeyboardMan'
```## Contact
NIX [@nixzhu](https://twitter.com/nixzhu)
## License
KeyboardMan is available under the MIT license. See the LICENSE file for more info.