Last active
October 26, 2021 18:44
-
-
Save tadija/88779a34d66bb5acff5c9513c78fe885 to your computer and use it in GitHub Desktop.
AEHaptic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* https://gist.github.com/tadija/88779a34d66bb5acff5c9513c78fe885 | |
* Revision 5 | |
* Copyright © 2018-2021 Marko Tadić | |
* Licensed under the MIT license | |
*/ | |
import UIKit | |
@available(iOS 10.0, *) | |
public struct AEHaptic { | |
public static func success() { | |
let feedback = UINotificationFeedbackGenerator() | |
feedback.notificationOccurred(.success) | |
} | |
public static func warning() { | |
let feedback = UINotificationFeedbackGenerator() | |
feedback.notificationOccurred(.warning) | |
} | |
public static func error() { | |
let feedback = UINotificationFeedbackGenerator() | |
feedback.notificationOccurred(.error) | |
} | |
public static func impactLight() { | |
let feedback = UIImpactFeedbackGenerator(style: .light) | |
feedback.impactOccurred() | |
} | |
public static func impactMedium() { | |
let feedback = UIImpactFeedbackGenerator(style: .medium) | |
feedback.impactOccurred() | |
} | |
public static func impactHeavy() { | |
let feedback = UIImpactFeedbackGenerator(style: .heavy) | |
feedback.impactOccurred() | |
} | |
public static func selection() { | |
let feedback = UISelectionFeedbackGenerator() | |
feedback.selectionChanged() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment