Swiftpack.co - LudvigSahlin/FeedbackButton as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
This package is used to easily create tap feedback.
.package(url: "https://github.com/LudvigSahlin/FeedbackButton.git", from: "0.1.0")


This package is used to easily create tap feedback.

  • Add a tap recognizer to any given UIView by adding a subclassed UIButton as a subview.
  • Specify code to be run when the view is tapped (touchDown).
  • Specify code to be run when the tap is finished in any way (touchUpInside, touchCancel, touchDragExit, etc.).
  • Specify code to be run when the tap is released inside the view (touchUpInside).


  • Prevents double taps. If any tap is currently being handled, all other taps on any FeedbackButton will be ignored.


Typically you would create an extension function to UIView like this:

extension UIView {
    func applyFeedback(showFeedback: @escaping (Bool) -> (), onTouchUpInside: @escaping () -> ()) {
        let feedbackButton = FeedbackButton(showFeedback: showFeedback, onTouchUpInside: onTouchUpInside)
        feedbackButton.constrainTo(self, .allBorders) // Note: This function is defined in the Swift package "Constraint".

Then you can specify the desired code for any UIView that should react on tap events:

xBackgroundView.applyFeedback(showFeedback: { feedback in
    if feedback {
        xImageView.tintColor = .systemGray5
    } else {
        xImageView.tintColor = .systemGray4
}, onTouchUpInside: {
    textField.text = ""


The contents of this repository is licensed under the Apache License, version 2.0.




Stars: 0
Last commit: 3 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics