ScrollViewKeyboardAvoider 1.0.6

ScrollViewKeyboardAvoider 1.0.6

Maintained by Darrarski.



ScrollViewKeyboardAvoider

Platform Swift v4.2 Maintainability Test Coverage Build Status CocoaPods Carthage compatible

Adjust insets in UIScrollView so the keyboard does not cover content.

Install

Minimum deployment target: iOS 10.0 (on iOS 11 uses Safe Area Layout for iPhone X compatibility)

CocoaPods

You can integrate ScrollViewKeyboardAvoider with your project using CocoaPods. Just add this line to your Podfile:

pod 'ScrollViewKeyboardAvoider', '~> 1.0'

Carthage

You can also use Carthage if you prefer by adding following line to your Cartfile:

github "darrarski/ScrollViewKeyboardAvoider" ~> 1.0

Use

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)

Develop

Requirements:

To bootstrap the project run:

bundle install
bundle exec fastlane setup

Then 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 test

To generate and open test coverage report in HTML format, run:

bundle exec fastlane coverage

License

MIT License - check out LICENSE file.