Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/libsteve/adaptivetyping
A view controller to automatically adjust child view controllers when the iOS Keyboard appears.
https://github.com/libsteve/adaptivetyping
ios ios-ui ios11 swift uiviewcontroller
Last synced: 15 days ago
JSON representation
A view controller to automatically adjust child view controllers when the iOS Keyboard appears.
- Host: GitHub
- URL: https://github.com/libsteve/adaptivetyping
- Owner: libsteve
- License: other
- Created: 2018-03-03T02:47:43.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-14T17:04:21.000Z (almost 7 years ago)
- Last Synced: 2024-12-01T00:37:15.541Z (about 1 month ago)
- Topics: ios, ios-ui, ios11, swift, uiviewcontroller
- Language: Swift
- Homepage:
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
AdaptiveTyping
==============`KeyboardSafeAreaController` is a container view controller that will automatically
adjust its safe area insets in response to the iOS Keyboard appearing, disappearing,
and resizing.To use it, simply instantiate `KeyboardSafeAreaController` with a view controller
whose safe-area you want protected from the keyboard, and present that instance
as you would any other view controller. Voila! your view controller's safe-area
will resize whenever the keyboard appears, disappears, or changes in size.```swift
import AdaptiveTyping
import PlaygroundSupport
import UIKitPlaygroundPage.current.liveView = KeyboardSafeAreaController(rootViewController: ViewController())
class ViewController: UIViewController {
var field: UITextField!override func loadView() {
view = UIView()
view.backgroundColor = .whitefield = UITextField()
field.translatesAutoresizingMaksIntoConstraints = false
view.addSubview(field)field.text = "Apples are your friends"
field.textAlignment = .center[ field.centerXAnchor.constraint(equalTo: view.layoutMarginsGuide.centerXAnchor),
field.centerYAnchor.constraint(equalTo: view.layoutMarginsGuide.centerYAnchor),
field.widthAnchor.constraint(equalTo: view.layoutMarginsGuide.widthAnchor) ]
.forEach { $0.isActive = true }let tap = UITapGestureRecognizer(target: self, action: #selector(self.didTapAway))
view.addGestureRecognizer(tap)
}@objc func didTapAway() {
field.resignFirstResponder()
}
}
```