https://github.com/trademe/keyboarddodger
An iOS cocoapod that uses a constraint to move a view out of the way of the on-screen keyboard.
https://github.com/trademe/keyboarddodger
Last synced: about 1 year ago
JSON representation
An iOS cocoapod that uses a constraint to move a view out of the way of the on-screen keyboard.
- Host: GitHub
- URL: https://github.com/trademe/keyboarddodger
- Owner: TradeMe
- License: mit
- Created: 2017-05-11T22:24:43.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-06-17T22:47:03.000Z (about 7 years ago)
- Last Synced: 2025-04-11T05:18:27.147Z (about 1 year ago)
- Language: Swift
- Size: 20.5 KB
- Stars: 4
- Watchers: 12
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## KeyboardDodger
KeyboardDodger is an iOS cocoapod that uses a constraint to move a view out of the way of the on-screen keyboard.
### Installation
```ruby
pod 'KeyboardDodger', '~> 1.0'
```
### Usage
KeyboardDodger attaches to a view and a constraint at the bottom of the view, and manipulates the constraint to keep it out of the way of the on-screen keyboard.
An example implementation:
```swift
class ViewController: UIViewController {
var bottomConstraint: NSLayoutConstraint?
var keyboardDodger: KeyboardDodger?
override func viewDidLoad() {
super.viewDidLoad()
if let bottomConstraint = bottomConstraint {
keyboardDodger = KeyboardDodger(view: view, constraint: bottomConstraint, delegate: self)
}
}
}
extension ViewController: KeyboardDodgerDelegate {
func keyboardDodger(_ keyboardDodger: KeyboardDodger, willUpdateConstraintWith transition: KeyboardDodgerTransition) {
print("Keyboard dodger will update constraint")
}
func keyboardDodger(_ keyboardDodger: KeyboardDodger, didUpdateConstraintWith transition: KeyboardDodgerTransition) {
print("Keyboard dodger did update constraint")
}
func keyboardDodger(_ keyboardDodger: KeyboardDodger, willResetConstraintWith transition: KeyboardDodgerTransition) {
print("Keyboard dodger will reset constraint")
}
func keyboardDodger(_ keyboardDodger: KeyboardDodger, didResetConstraintWith transition: KeyboardDodgerTransition) {
print("Keyboard dodger did reset constraint")
}
}
```