efremidze / Haptica

Easy Haptic Feedback Generator 📳
MIT License
759 stars 43 forks source link
apple carthage cocoapods feedback generator haptic ios ios10 notes patterns swift taptic uibutton vibrate

Haptica

Build Status Carthage Compatible Language Version License Platform

Haptica is an easy haptic feedback generator.

$ pod try Haptica

Requirements

Haptic Feedback Requirements:

Usage

Generate using a haptic feedback type.

Haptic.impact(.light).generate()

Feedback Types

Vibration Patterns

Play a custom vibration pattern:

Haptic.play("..oO-Oo..", delay: 0.1)

Use pattern symbols to represent custom vibrations.

Or play a symphony of notes:

Haptic.play([.haptic(.impact(.light)), .haptic(.impact(.heavy)), .wait(0.1), .haptic(.impact(.heavy)), .haptic(.impact(.light))])

UIButton Extension

To enable haptic feedback on buttons, set these properties:

button.isHaptic = true
button.hapticType = .impact(.light)

or use these functions to set the haptic feedback type 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

Mentions

License

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