All Projects → johnpatrickmorgan → KeyboardLayoutGuide

johnpatrickmorgan / KeyboardLayoutGuide

Licence: MIT license
Enables you to set up Auto Layout constraints directly between your views and the iOS keyboard.

Programming Languages

swift
15916 projects
shell
77523 projects
perl
6916 projects
ruby
36898 projects - #4 most used programming language
objective c
16641 projects - #2 most used programming language
Roff
2310 projects

Projects that are alternatives of or similar to KeyboardLayoutGuide

iOS-11-Framer
iOS 11 Design System GUI for Framer
Stars: ✭ 42 (-23.64%)
Mutual labels:  uikit
KBImageView
UIImageView with Ken Burns effect.
Stars: ✭ 48 (-12.73%)
Mutual labels:  uikit
ALRadioButtons
RadioButtons for iOS. Inherited from UIControl, support 2 native styles, fully customizable.
Stars: ✭ 65 (+18.18%)
Mutual labels:  uikit
shock
Free business application template, front & dashborad, build on vuetify
Stars: ✭ 16 (-70.91%)
Mutual labels:  uikit
Builder
Demonstrates SwiftUI builder patterns for UIKit and networking.
Stars: ✭ 100 (+81.82%)
Mutual labels:  uikit
UIViewPreviewProvider
Allows displaying UIViews inside the Xcode preview canvas
Stars: ✭ 36 (-34.55%)
Mutual labels:  uikit
SimplePagedView
A UIPageViewController replacement built to be as simple as possible
Stars: ✭ 77 (+40%)
Mutual labels:  uikit
ALProgressView
Animated and fully customizable progress view with 2 styles: ring and bar.
Stars: ✭ 72 (+30.91%)
Mutual labels:  uikit
NavigationRouter
A router implementation designed for complex modular apps, written in Swift
Stars: ✭ 89 (+61.82%)
Mutual labels:  uikit
SheeKit
Customize and resize sheets in SwiftUI with SheeKit. Utilise the power of `UISheetPresentationController` and other UIKit features.
Stars: ✭ 56 (+1.82%)
Mutual labels:  uikit
mdb-vue-ui-kit
Vue 3 & Bootstrap 5 & Material Design 2.0 UI KIT
Stars: ✭ 887 (+1512.73%)
Mutual labels:  uikit
CLE-Architecture-Tools
A library for making view controller presentation and dismissal more functional.
Stars: ✭ 32 (-41.82%)
Mutual labels:  uikit
TimedSilver
All about swift extensions 😉
Stars: ✭ 75 (+36.36%)
Mutual labels:  uikit
BJOTPViewController
Entering OTP made simpler.
Stars: ✭ 42 (-23.64%)
Mutual labels:  uikit
Driftwood
Driftwood is a DSL to make Auto Layout easy on iOS, tvOS and macOS.
Stars: ✭ 14 (-74.55%)
Mutual labels:  uikit
VCore
VCore is a Swift collection containing objects, functions, and extensions that I use for my projects
Stars: ✭ 32 (-41.82%)
Mutual labels:  uikit
plexydesk
Lightweight Desktop Manager for Gnu/Linux and FreeBSD - Ideal for Low resource computers
Stars: ✭ 33 (-40%)
Mutual labels:  uikit
UIKit-CXX
Simple UIKit application written in C++ using the OBJCXX library.
Stars: ✭ 15 (-72.73%)
Mutual labels:  uikit
awesome-ios
A collaborative list of awesome for iOS developers. Include quick preview.
Stars: ✭ 1,329 (+2316.36%)
Mutual labels:  uikit
sendbird-javascript-samples
A guide of the installation and functions of Sendbird Chat, UIKit, and SyncManager for JavaScript samples.
Stars: ✭ 315 (+472.73%)
Mutual labels:  uikit

⌨️ KeyboardLayoutGuide ⌨️

Version License Swift

Imagine being able to set up Auto Layout constraints directly between your views and the iOS keyboard, so that your layout updates whenever the keyboard's frame changes. KeyboardLayoutGuide makes that possible, providing options to do so entirely within Interface Builder, or in code via a simple interface:

constrainKeyboard(myView) { keyboard, myView in
    
    // create and return your keyboard-based constraints
}

Usage

Via code

Declare your view controller to conform to KeyboardConstraining. This is an empty protocol that makes a number of methods available, so that you can do something like:

constrainKeyboard(contentView) { keyboard, contentView in
    
    return [keyboard.topAnchor.constraint(equalTo: contentView.bottomAnchor)]
}

The bottom of contentView will now be constrained to the top of the keyboard, and will update whenever the keyboard's frame changes. You can use vanilla Auto Layout or any third-party library for creating the constraints. They will be activated when the view is added to a window, and deactivated on viewWillDisappear.

For a more complex example, imagine a view where the bottom of the table view should rest on the top of the tab bar, or the top of the keyboard, whichever is higher. In that instance, you would constrain the bottom of your tableView to the top of the bottomLayoutGuide, with a priority lower than 1000 (since it needs to be broken when the keyboard appears). When coupled with an inequality constraint with the keyboard, this will ensure the correct behaviour:

constrainKeyboard(tableView) { keyboard, tableView in
    
    return [keyboard.topAnchor.constraint(greaterThanOrEqualTo: tableView.bottomAnchor)]
}

Via Interface Builder

Simply add a new UIView to your view. This will be your keyboard proxy, so assign it to your view controller's klg_keyboardProxy property. At runtime, the keyboard proxy's frame will be constrained to match that of the keyboard, so you can add any constraints you wish between your other views and the keyboard proxy.

Although constraints will be added at runtime, you still need to satisfy Interface Builder that the keyboard proxy has a valid layout. Add leading, trailing, bottom and height constraints between the proxy and its superview. These placeholder constraints will satisfy Interface Builder, but you should ensure they are removed at build time by checking Placeholder ☑ Remove at build time for each one in Interface Builder. You can preview how your layout changes when the keyboard appears by adjusting the height constraint on your keyboard proxy.

How does it work?

LifecycleHooks are used to add lifecycle-driven behaviour to your view controller. The keyboard layout guide is attached to the window itself, so its frame is not affected by changes in your view's frame.

Installation

CocoaPods

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

pod "KeyboardLayoutGuide"

Carthage

Add the following to your Cartfile:

github "johnpatrickmorgan/KeyboardLayoutGuide"

Swift Package Manager

Adding the following to the dependencies array of your Package.swift:

dependencies: [
	.package(url: "https://github.com/johnpatrickmorgan/KeyboardLayoutGuide.git", from: "0.7.1")
]

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].