Skip to content

efremidze/Haptica

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

74 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Haptica

CI CocoaPods Carthage SPM Swift License

Haptica

Haptica is a simple and expressive haptic feedback generator for iOS.

$ pod try Haptica

πŸ“± Requirements

Haptica Version iOS Swift Xcode
4.x 13+ 5.x 11+
3.x 9+ 5.x 8+
2.x 9+ 4.x 8+
1.x 9+ 3.x 8+

Haptic Feedback Requirements

  • Device with a supported Taptic Engine
  • App running in the foreground
  • System Haptics setting enabled

πŸš€ Usage

Trigger a haptic feedback with a single line:

Haptic.impact(.light).generate()

Feedback Types

  • Impact (.light, .medium, .heavy, .soft, .rigid)
    Use to indicate collision or snap-to-position.
  • Notification (.success, .warning, .error)
    Use to communicate task results.
  • Selection
    Use for navigation through discrete values.

Semantic Types (New)

Use new expressive variants for common interactions:

Haptic.success.generate()
Haptic.warning.generate()
Haptic.start.generate()
Haptic.stop.generate()
Haptic.increase.generate()
Haptic.decrease.generate()

These semantic styles internally map to appropriate UIKit or Core Haptics-based effects.

Custom Vibration Patterns

Haptic.play("..oO-Oo..", delay: 0.1)
Symbol Feedback Type
. Light impact
o Medium impact
O Heavy impact
x Soft impact
X Rigid impact
- 0.1s pause

Or use structured notes:

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

πŸ”§ Core Haptics Support

Haptica uses Core Haptics by default when available. To use the legacy API:

Haptic.play(notes, legacy: true)

πŸ“‚ Play from Pattern File (New) - iOS 16+

Play a Core Haptics pattern from a bundled .ahap file:

Haptic.playPattern(named: "Feedback")

Make sure the file is included in your app bundle and contains a valid haptic pattern.


🧹 UIButton Extension

Enable haptics for buttons easily:

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

Add or remove haptic feedback on control events:

button.addHaptic(.selection, forControlEvents: .touchDown)
button.removeHaptic(forControlEvents: .touchDown)

API Summary:

var isHaptic: Bool
var hapticType: Haptic?
var hapticControlEvents: UIControl.Event?

func addHaptic(_ haptic: Haptic, forControlEvents events: UIControl.Event)
func removeHaptic(forControlEvents events: UIControl.Event)

πŸ”Š Sound Effects

Integrate sound feedback with Peep:

Peep.play(sound: KeyPress.tap)

πŸ“¦ Installation

Swift Package Manager

// For iOS 13+
.package(url: "https://github.com/efremidze/Haptica.git", from: "4.0.0")

// For iOS 9
.package(url: "https://github.com/efremidze/Haptica.git", from: "3.0.0")

CocoaPods

use_frameworks!
pod "Haptica"

Carthage

github "efremidze/Haptica"

πŸ’¬ Communication


πŸ“° Mentions


πŸ“„ License

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

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy