All Projects → KaneCheshire → HapticGenerator

KaneCheshire / HapticGenerator

Licence: MIT license
Easy peasy haptic generation in iOS.

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to HapticGenerator

Meme-Maker-iOS
Meme Maker open source iOS app made in Swift.
Stars: ✭ 59 (+84.38%)
Mutual labels:  iphone, ipad
Customized-Popup
Customized popup provides you independency related to how you want to show a popup according to your UX.
Stars: ✭ 13 (-59.37%)
Mutual labels:  iphone, ipad
SignTools-CI
Sign iOS apps on demand using CI. Part of: https://github.com/SignTools/SignTools
Stars: ✭ 145 (+353.13%)
Mutual labels:  iphone, ipad
Ios
IRCCloud iOS App
Stars: ✭ 243 (+659.38%)
Mutual labels:  iphone, ipad
BJOTPViewController
Entering OTP made simpler.
Stars: ✭ 42 (+31.25%)
Mutual labels:  iphone, ipad
Chipagecontrol
A set of cool animated page controls written in Swift to replace boring UIPageControl. Mady by @ChiliLabs - https://chililabs.io
Stars: ✭ 2,909 (+8990.63%)
Mutual labels:  iphone, ipad
Shukofukurou-iOS
The Ultimate Open Source AniList, Kitsu, and MyAnimeList Tracker for iOS/iPadOS written in Objective-C
Stars: ✭ 29 (-9.37%)
Mutual labels:  iphone, ipad
Ios
OwnTracks' iPhone App
Stars: ✭ 222 (+593.75%)
Mutual labels:  iphone, ipad
NDILiteSenderPlugin
NDI™ send-only plugin for Unity macOS/iOS
Stars: ✭ 49 (+53.13%)
Mutual labels:  iphone, ipad
YMTGetDeviceName
Get device name from model number
Stars: ✭ 27 (-15.62%)
Mutual labels:  iphone, ipad
TOFileSystemObserver
A bullet-proof mechanism for detecting any changes made to the contents of a folder in iOS and macOS.
Stars: ✭ 35 (+9.38%)
Mutual labels:  iphone, ipad
ALButtonMenu
A simple, fully customizable menu solution for iOS.
Stars: ✭ 45 (+40.63%)
Mutual labels:  iphone, ipad
Uicollectionviewsplitlayout
UICollectionViewSplitLayout makes collection view more responsive.
Stars: ✭ 226 (+606.25%)
Mutual labels:  iphone, ipad
eve-of-impact
🌍☄️ Eve of Impact iOS game source code
Stars: ✭ 32 (+0%)
Mutual labels:  iphone, ipad
Stpopup
STPopup provides STPopupController, which works just like UINavigationController in popup style, for both iPhone and iPad. It's written in Objective-C and compatible with Swift.
Stars: ✭ 2,517 (+7765.63%)
Mutual labels:  iphone, ipad
SwiftyJot
Use your finger to annotate images.
Stars: ✭ 14 (-56.25%)
Mutual labels:  iphone, ipad
Stpopuppreview
An alternative peek preview for non 3D Touch devices. Inspired by Instagram.
Stars: ✭ 202 (+531.25%)
Mutual labels:  iphone, ipad
Hls Vod
HTTP Live Streaming with on-the-fly encoding of any video file for Web/Apple TV/iPhone/iPad/iPod
Stars: ✭ 221 (+590.63%)
Mutual labels:  iphone, ipad
iOSShortcuts
A collection of shortcuts for the Shortcuts app.
Stars: ✭ 60 (+87.5%)
Mutual labels:  iphone, ipad
iPatch
Patch iPA Files With Dynamic Libraries
Stars: ✭ 29 (-9.37%)
Mutual labels:  iphone, ipad

HapticGenerator

Easy peasy haptic generation in iOS.

CI Status Version License Platform

Installation

Swift Package Manager

HapticGenerator supports SPM, simply add HapticGenerator as a package dependency in Xcode 11 or newer.

Cocoapods

Add the following to your podfile:

pod 'HapticGenerator'

and then run pod update in Terminal.

Manual

Or you can just add HapticGenerator.swift to your project manually.

Migrating from HapticGenerator 2 to HapticGenerator 3

HapticGenerator 3.0.0 significantly simplifies naming, but will be a breaking change requiring you to update your app.

In HapticGenerator 3, the line of code to generate a haptic has been simplified:

Haptic.selection.generate()
Haptic.selection.generate(prepareForReuse: true)

Compared to HapticGenerator 2 which was a bit too verbose for no real good reason:

HapticGenerator.selection.generateHaptic()
HapticGenerator.selection.generateHaptic(prepareForReuse: true)

Usage

HapticGenerator now comes with convenience constants so generating haptics is even easier:

Haptic.selection.generate()

Alternatively, if you'd rather create the generators yourself simply create a new generator like so:

let selection = Haptic(.selection)
let lightImpact = Haptic(.impact(.light))
let warning = Haptic(.notification(.warning))

And then generate a haptic like so:

selection.generate()

Optionally, you can tell the system to prepare the engine for (re)use. HapticGenerator has two ways to do this, either after you generate a haptic by setting prepareForReuse to true:

Haptic.selection.generate(prepareForReuse: true)

Or if you know in advance before generating a haptic that you'll need to use it soon (after a screen appears for example), then you can prepareForUse manually:

Haptic.selection.prepareForUse()

Note: Haptics should only be generated and prepared for reuse on the main thread.

Why use this?

Apple's UIFeedbackGenerator subclasses are not difficult to use, but they are messy.

HapticGenerator tidies this up and makes the process of creating different types of haptics on iOS easy and coherent.

See the difference between creating and using generators of different types Apple's way, and the HapticGenerator way:

// Apple's way of using a selection feedback generator:
let selection = UISelectionFeedbackGenerator()
// Generate the haptic:
selection.selectionChanged()

// Apple's way of using an impact feedback generator:
let lightImpact = UIImpactFeedbackGenerator(style: .light)
lightImpact.impactOccurred()

// Apple's way of using a notification feedback generator:
let success = UINotificationFeedbackGenerator()
success.notificationOccurred(.success)

Compared to the HapticGenerator way:

Haptic.selection.generate()

Haptic.lightImpact.generate()

Haptic.success.generate()

HapticGenerator is significantly less code to write and easier to follow.

Furthermore, if you support any iOS version prior to iOS 10, you won't have ugly availability checks throughout your code because it is all contained within HapticGenerator.

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