Latest 1.0.6
Homepage https://github.com/darrarski/ScrollViewKeyboardAvoider
License MIT
Platforms ios 10.0, requires ARC
Frameworks UIKit
Authors

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.

Latest podspec

{
    "name": "ScrollViewKeyboardAvoider",
    "version": "1.0.6",
    "summary": "Adjust insets in UIScrollView so the keyboard does not cover content",
    "homepage": "https://github.com/darrarski/ScrollViewKeyboardAvoider",
    "authors": {
        "Dariusz Rybicki": "[email protected]"
    },
    "social_media_url": "https://twitter.com/darrarski",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "source": {
        "git": "https://github.com/darrarski/ScrollViewKeyboardAvoider.git",
        "tag": "v1.0.6"
    },
    "platforms": {
        "ios": "10.0"
    },
    "swift_version": "4.2",
    "source_files": "Sources",
    "requires_arc": true,
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This