All Projects → niw → Keyboardguide

niw / Keyboardguide

Licence: mit
A modern, real iOS keyboard system notifications handler framework that Just Works.

Programming Languages

swift
15916 projects

Labels

Projects that are alternatives of or similar to Keyboardguide

Sancho
Responsive and accessible React UI components built with Typescript
Stars: ✭ 365 (-13.92%)
Mutual labels:  uikit
Tlyshynavbar
Unlike all those arrogant UINavigationBar, this one is shy and humble! Easily create auto-scrolling navigation bars!
Stars: ✭ 3,780 (+791.51%)
Mutual labels:  uikit
Uicollectionview Layouts Kit
📐 A set of custom layouts for UICollectionView with examples [Swift 5.3, iOS 12].
Stars: ✭ 410 (-3.3%)
Mutual labels:  uikit
Awesome Flutter Ui
10+ flutter(android, ios) UI design examples ⚡️ - login, books, profile, food order, movie streaming, walkthrough, widgets
Stars: ✭ 372 (-12.26%)
Mutual labels:  uikit
Shadowview
An iOS Library that makes shadows management easy on UIView.
Stars: ✭ 391 (-7.78%)
Mutual labels:  uikit
Swiftuikitview
Easily use UIKit views in your SwiftUI applications. Create Xcode Previews for UIView elements
Stars: ✭ 398 (-6.13%)
Mutual labels:  uikit
Shards Dashboard Vue
A free Vue admin dashboard template pack featuring a modern design system and lots of custom templates and components.
Stars: ✭ 363 (-14.39%)
Mutual labels:  uikit
Owl
A declarative type-safe framework for building fast and flexible lists with UITableViews & UICollectionViews
Stars: ✭ 423 (-0.24%)
Mutual labels:  uikit
Stepslider
StepSlider its custom implementation of slider such as UISlider for preset integer values.
Stars: ✭ 391 (-7.78%)
Mutual labels:  uikit
Panelkit
PanelKit is a UI framework that enables panels on iOS. A panel can be presented in the following ways:
Stars: ✭ 3,835 (+804.48%)
Mutual labels:  uikit
Epoxy Ios
Epoxy is a suite of declarative UI APIs for building UIKit applications in Swift
Stars: ✭ 377 (-11.08%)
Mutual labels:  uikit
Shards Vue
🌟Shards Vue is a free, beautiful and modern Vue.js UI kit based on Shards.
Stars: ✭ 390 (-8.02%)
Mutual labels:  uikit
Squishbutton
A button that squishes when pressed. As seen in the Clips app.
Stars: ✭ 401 (-5.42%)
Mutual labels:  uikit
Starwars.ios
This component implements transition animation to crumble view-controller into tiny pieces.
Stars: ✭ 3,685 (+769.1%)
Mutual labels:  uikit
Cards
Awesome iOS 11 appstore cards in swift 5.
Stars: ✭ 4,017 (+847.41%)
Mutual labels:  uikit
Overwatch Ui
A UI library of Overwatch, built with Vue.js
Stars: ✭ 365 (-13.92%)
Mutual labels:  uikit
Acknowlist
Acknowledgements screen displaying a list of licenses, for example from CocoaPods dependencies.
Stars: ✭ 392 (-7.55%)
Mutual labels:  uikit
Uikit Cross Platform
Cross-platform Swift implementation of UIKit, mostly for Android
Stars: ✭ 421 (-0.71%)
Mutual labels:  uikit
Tweetextfield
Lightweight set of text fields with nice animation and functionality. 🚀 Inspired by https://uimovement.com/ui/2524/input-field-help/
Stars: ✭ 421 (-0.71%)
Mutual labels:  uikit
Restaurantappuikit
Flutter representation of a full Restaurant app UI KIT.
Stars: ✭ 400 (-5.66%)
Mutual labels:  uikit

KeyboardGuide

A modern, real iOS keyboard system notifications handler framework that Just Works.

KeyboardGuide

As you know, handling the keyboard on iOS was just a nightmare.

On the internet, there are many, many iOS keyboard handler implementations for system notifications such as UIResponder.keyboardWillChangeFrameNotification (UIKeyboardWillChangeFrameNotification), but most of them are not implemented properly.

For example, many of them are not converting the keyboard frame in the right coordinate or not considering iPad keyboard behaviors. Also, there are many undocumented behaviors that are not consistent between each iOS version.

This framework is solving this problem.

Based on years experience of iOS application development and various tests on each iOS version and device, it supports both Swift and Objective-C and works mostly reasonably on the latest 3 versions of iOS, which is iOS 11, 12 and iOS 13 now, and covers almost all iOS users.

Usage

Using KeyboardGuide is really simple. See also Examples for actual usage, that contains Swift and Objective-C code for testing.

Add KeyboardGuide framework to your project

Add the following lines to your Package.swift or use Xcode “Add Package Dependency…” menu.

// In your `Package.swift`

dependencies: [
    // ...
    .package(url: "https://github.com/niw/KeyboardGuide.git"),
    // ...
]

Using KeyboardGuide with the other dependency management tools.

KeyboardGuide doesn’t support directly the other dependency management tools than Swift Package Manager. However, since it has no dependencies other than system frameworks, you can still use it from the other dependency management tools.

CocoaPods

To use KeyboardGuide from CocoaPods, add following KeyboardGuide.podspec file in your project.

Pod::Spec.new do |spec|
  spec.name = "KeyboardGuide"
  spec.version = "0.2.0" # Find the current version from the version tags.
  spec.authors = ""
  spec.summary = "KeyboardGuide"
  spec.homepage = "https://github.com/niw/KeyboardGuide"
  spec.platform = :ios, "11.0"
  spec.source = {
    :git => "https://github.com/niw/KeyboardGuide.git", :tag => "#{spec.version}"
  }
  spec.source_files  = "Sources/KeyboardGuide/*.swift"
end

Then, update Podfile in your project.

pod 'KeyboardGuide', :podspec => 'path/to/KeyboardGuide.podspec'

Carthage

To use KeyboardGuide from Carthage, update Cartfile in your project.

github "niw/KeyboardGuide"

Then, run following commands. This will create Carthage/Build/iOS/KeyboardGuide.framework.

$ carthage update
$ (cd Carthage/Checkouts/KeyboardGuide && swift package generate-xcodeproj)
$ carthage build --platform iOS

Follow the instruction to add the framework and Run Script phase to your project.

Setup KeyboardGuide

Add import KeyboardGuide.

Use KeyboardGuide.shared.activate() to activate KeyboardGuide at the beginning of application life cycle, such as application(_:didFinishLaunchingWithOptions:).

// In your `UIApplicationDelegate`

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    KeyboardGuide.shared.activate()
    // ...
}

Add constraints on your views

Lay out your views by adding constraints to view.keyboardSafeArea.layoutGuide, where represents the safe area from, not covered by the keyboard.

It works as like safeAreaLayoutGuide for the notch.

// In your `UIViewController`

override func viewDidLoad() {
    super.viewDidLoad()
    // ...
    let textView = UITextView()
    textView.translatesAutoresizingMaskIntoConstraints = false
    // ...
    textView.bottomAnchor.constraint(equalTo: view.keyboardSafeArea.layoutGuide.bottomAnchor).isActive = true
    // ...
}

Manual layout

If you prefer to manually lay out your views or need to use length of keyboard safe area, for such as updating UIScrollView’s contentInset, override viewDidLayoutSubviews() or layoutSubviews() as like regular manual lay outing.

// In your `UIViewController`

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    // ...
    let bottomInset = view.keyboardSafeArea.insets.bottom
    textView.contentInset.bottom = bottomInset
    textView.scrollIndicatorInsets.bottom = bottomInset
}

The important layout behavior

If your view doesn’t have any sub views that have at least one constraint to view.keyboardSafeArea.layoutGuide, UIKit MAY NOT call layoutSubviews (or similar callbacks such as viewDidLayoutSubviews).

Because in general, the keyboard safe area has a relative layout relationship between the keyboard position where is outside of the view but in the screen, UIKit doesn’t know that relationship without a constraint.

For example, on iOS 13, if a view controller is presented as a modal on iPad in portrait, when the keyboard is appearing, that modal view controller is moved upwards by UIKit. This move changes the relative position of your view to the keyboard, however, UIKit doesn’t call your layoutSubviews (which is obvious,) but for keyboard safe area, you MAY need to re lay out your sub views.

Therefore, you MAY need to add at least one constraint to view.keyboardSafeArea.layoutGuide from one of your sub views, to let UIKit knows view has that relationship.

Known limitations

There are a few known limitations in the current implementation. All limitations are currently To-Do of this project.

  • No SwiftUI support yet.

  • Share extension can’t use this library yet because of UIApplication dependency.

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].