Swiftpack.co -  hainayanda/Clavier as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
hainayanda/Clavier
Clavier is Keyboard Layout Guide for iOS. It using an intersection frame to calculate the Layout Guide.
.package(url: "https://github.com/hainayanda/Clavier.git", from: "1.0.2")

Clavier

Clavier is Keyboard Layout Guide for iOS. It using an intersection frame to calculate the Layout Guide.

codebeat badge build test SwiftPM Compatible Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • Swift 5.1 or higher
  • iOS 10.0 or higher

Installation

Requirements

  • Swift 5.1 or higher
  • iOS 10.0 or higher

Cocoapods

Clavier is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Clavier', '~> 1.0'

Swift Package Manager from XCode

  • Add it using XCode menu File > Swift Package > Add Package Dependency
  • Add https://github.com/hainayanda/Clavier.git as Swift Package URL
  • Set rules at version, with Up to Next Major option and put 1.0.2 as its version
  • Click next and wait

Swift Package Manager from Package.swift

Add as your target dependency in Package.swift

dependencies: [
    .package(url: "https://github.com/hainayanda/Clavier.git", .upToNextMajor(from: "1.0.2"))
]

Use it in your target as Clavier

 .target(
    name: "MyModule",
    dependencies: ["Clavier"]
)

Author

Nayanda Haberty, hainayanda@outlook.com

License

Clavier is available under the MIT license. See the LICENSE file for more info.


Basic Usage

Clavier is the Keyboard Layout Guide created to make constraints to the keyboard. It will automatically change on the keyboard changes. It calculates the intersection frame of the Keyboard and the UIView. As you can see in the picture below:

alt text

If the keyboard did not intersect with the view, it will always use the most bottom of the UIView with zero height for the regular one, or most bottom of the safe area when using a safe one

alt text

If the keyboard is hidden, it will always use the most bottom of the UIView with zero height for the regular one, or most bottom of the safe area when using a safe one

Usage

To use Clavier, just use keyboardLayoutGuide from any UIView, or safeKeyboardLayoutGuide if you prefer the one intersect with the safe area. it is an instance of KeyboardLayoutGuide class which extend UILayoutGuide so it has all its anchors, like topAnchor, leadingAnchor, etc:

myView.bottomAnchor.constraints(equalTo: mySuperview.keyboardLayoutGuide.topAnchor)

or with safe area:

myView.bottomAnchor.constraints(equalTo: mySuperview.safeKeyboardLayoutGuide.topAnchor)

myView will automatically move according to keyboard layout guide frame changes.

Since its subclass of UILayoutGuide, it has layoutFrame which is the intersection frame with keyboard frame, if you need it:

let frameIntersectWithKeyboard: CGRect = view.keyboardLayoutGuide.layoutFrame

or with safe area:

let frameIntersectWithKeyboard: CGRect = view.safeKeyboardLayoutGuide.layoutFrame

Contribute

You know how, just clone and do pull request

GitHub

link
Stars: 0
Last commit: 1 week ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Dependencies

Release Notes

v1.0.2
1 week ago

Update username

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API