DEV Community

Cover image for Haptic Feedback for the Feels - #30DaysOfSwift
Vaibhav Dwivedi
Vaibhav Dwivedi

Posted on โ€ข Edited on

Haptic Feedback for the Feels - #30DaysOfSwift

Day 3: The earthly vibrations caught my off guard. ๐Ÿ’‚

In the Fourth post of #30DaysOfSwift series, You'll learn how to implement the haptic feedback on press of a Button or any certain action.

Here's the code for you to implement Haptic Feedback with 3 variations.

Image description

For those who want to jump into it right away,

struct HomeView: View {
    let lightFeedback = UIImpactFeedbackGenerator(style: .light) // Change style
    let mediumFeedback = UIImpactFeedbackGenerator(style: .medium) 
    let heavyFeedback = UIImpactFeedbackGenerator(style: .heavy)

    var body: some View {
        Button("Light Feedback") {
            lightFeedback.impactOccurred() // Use this line for haptic feedback
        }

        Button("Medium Feedback") {
            mediumFeedback.impactOccurred()
        }

        Button("Heavy Feedback") {
            heavyFeedback.impactOccurred()
        }
    }

}
Enter fullscreen mode Exit fullscreen mode

Which one hits the right spot? Let me know :)

Happy Coding!

Image of Timescale

๐Ÿš€ pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applicationsโ€”without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post โ†’

Top comments (0)

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Googleโ€™s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More