Haptica is an easy haptic feedback generator.
$ pod try Haptica
- iOS 9.0+
- Xcode 8.0+
- Swift 4 (Haptica 2.x), Swift 3 (Haptica 1.x)
- A device with a supported Taptic Engine (iPhone 7 and iPhone 7 Plus).
- App is running in the foreground.
- System Haptics setting is enabled.
Generate using a haptic feedback type.
Haptic.impact(.light).generate()
- Impact: (UIImpactFeedbackStyle) - Use impact feedback generators to indicate that an impact has occurred. For example, you might trigger impact feedback when a user interface object collides with something or snaps into place.
- light
- medium
- heavy
- Notification: (UINotificationFeedbackType) - Use notification feedback to communicate that a task or action has succeeded, failed, or produced a warning of some kind.
- success
- warning
- error
- Selection - Use selection feedback to communicate movement through a series of discrete values.
To enable haptic feedback on buttons, set these properties:
isHaptic
- enables haptic feedbackhapticType
- haptic feedback type
button.isHaptic = true
button.hapticType = .impact(.light)
var isHaptic: Bool // enables haptic feedback
var hapticType: Haptic? // haptic feedback type
var hapticControlEvents: UIControlEvents? // haptic feedback control events
Add sound effects to Haptica using Peep.
Peep.play(sound: KeyPress.tap)
To install with CocoaPods, simply add this in your Podfile
:
use_frameworks!
pod "Haptica"
To install with Carthage, simply add this in your Cartfile
:
github "efremidze/Haptica"
- If you found a bug, open an issue.
- If you have a feature request, open an issue.
- If you want to contribute, submit a pull request.
Haptica is available under the MIT license. See the LICENSE file for more info.