Easy Haptic Feedback Generator 📳
Clone or download
Latest commit 6ef6d82 Dec 5, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Update CONTRIBUTING.md Dec 6, 2017
Example 2.2.0 Oct 2, 2018
Haptica.xcodeproj 2.2.2 (#13) Dec 6, 2018
Images Updated Logo Apr 28, 2018
Sources 2.2.2 (#13) Dec 6, 2018
docs 2.2.1 Oct 2, 2018
.gitignore Initial commit Mar 31, 2017
.swift-version 2.2.0 Oct 2, 2018
.travis.yml 2.2.1 Oct 2, 2018
CHANGELOG.md 2.2.2 (#13) Dec 6, 2018
Haptica.podspec 2.2.2 (#13) Dec 6, 2018
LICENSE Initial commit Mar 31, 2017
Package.swift 1.0.1 Apr 7, 2017
README.md 2.2.2 (#13) Dec 6, 2018

README.md

Haptica

Build Status Version License Platform Carthage compatible

Haptica is an easy haptic feedback generator.

$ pod try Haptica

Requirements

  • iOS 9.0+
  • Xcode 8.0+
  • Swift 4 (Haptica 2.x), Swift 3 (Haptica 1.x)

Haptic Feedback Requirements:

  • A device with a supported Taptic Engine (iPhone 7 and iPhone 7 Plus).
  • App is running in the foreground.
  • System Haptics setting is enabled.

Usage

Generate using a haptic feedback type.

Haptic.impact(.light).generate()

Feedback Types

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

UIButton Extension

To enable haptic feedback on buttons, set these properties:

  • isHaptic - enables haptic feedback
  • hapticType - haptic feedback type
button.isHaptic = true
button.hapticType = .impact(.light)

or use these functions to set the haptic feedback type for control events:

  • addHaptic() - add haptic feedback for control events
  • removeHaptic() - remove haptic feedback for control events
button.addHaptic(.selection, forControlEvents: .touchDown)
button.removeHaptic(forControlEvents: .touchDown)

Functions/Properties

var isHaptic: Bool // enables haptic feedback
var hapticType: Haptic? // haptic feedback type
var hapticControlEvents: UIControl.Event? // haptic feedback control events
func addHaptic(_ haptic: Haptic, forControlEvents events: UIControl.Event) {} // add haptic feedback for control events
func removeHaptic(forControlEvents events: UIControl.Event) {} // remove haptic feedback for control events

Sound Effects

Add sound effects to Haptica using Peep.

Peep.play(sound: KeyPress.tap)

Installation

CocoaPods

To install with CocoaPods, simply add this in your Podfile:

use_frameworks!
pod "Haptica"

Carthage

To install with Carthage, simply add this in your Cartfile:

github "efremidze/Haptica"

Communication

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

Mentions

License

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