Adjust insets in UIScrollView so the keyboard does not cover content.
This project became a part of ScrollViewController.
It's obsolete and will no longer be maintained.
Minimum deployment target: iOS 10.0 (on iOS 11 uses Safe Area Layout for iPhone X compatibility)
You can integrate ScrollViewKeyboardAvoider with your project using CocoaPods. Just add this line to your Podfile:
pod 'ScrollViewKeyboardAvoider', '~> 1.0'You can also use Carthage if you prefer by adding following line to your Cartfile:
github "darrarski/ScrollViewKeyboardAvoider" ~> 1.0
You will need to setup keyboard frame observing, check out KeyboardFrameChangeListener if you need a simple solution. You can also check ScrollViewController which wrapps your custom view and handles all the logic automatically.
Example can be found in DemoApp.
TL;DR
let avoider: ScrollViewKeyboardAvoiding = ScrollViewKeyboardAvoider(
animator: { UIView.animate(withDuration: $0, animations: $1) }
)
let scrollView: UIScrollView
let newKeyboardFrame: CGRect
let keyboardAnimationDuration: TimeInterval
avoider.handleKeyboardFrameChange(newKeyboardFrame,
animationDuration: keyboardAnimationDuration,
for: scrollView)Requirements:
- Ruby with Bundler
- Xcode 10
To bootstrap the project run:
bundle install
bundle exec fastlane setupThen open ScrollViewKeyboardAvoider.xcodeproj in Xcode.
Use DemoApp build scheme for building and runing demo app.
Use Tests build scheme for runing tests.
To run tests from command line execute:
bundle exec fastlane testTo generate and open test coverage report in HTML format, run:
bundle exec fastlane coverageMIT License - check out LICENSE file.