Skip to content

Instantly share code, notes, and snippets.

@maxamly
maxamly / TappableContentView.swift
Created March 20, 2025 07:39 — forked from danhalliday/TappableContentView.swift
SwiftUI solution for responsive, instantly-tappable tiles in a scroll view.
import SwiftUI
/// SwiftUI implementation of a responsive-feeling scrollview with tappable tiles.
/// We use a custom UIScrollView via UIViewRepresentable and a UIView tap overlay to
/// get around current SwiftUI issues with simultaneous gesture recognition and allow
/// the tiles to respond instantly to presses while scrolling.
struct ContentView: View {
@State private var showSheet = false
import SwiftUI
struct ScaledButtonStyleTest: ButtonStyle {
func makeBody(configuration: Configuration) -> some View {
configuration.label
.scaleEffect(configuration.isPressed ? 0.2 : 1.0)
.animation(
.spring(response: 0.2, dampingFraction: 1),
value: configuration.isPressed
)
import SwiftUI
struct ScaledButtonStyleTest: ButtonStyle {
func makeBody(configuration: Configuration) -> some View {
configuration.label
.scaleEffect(configuration.isPressed ? 0.2 : 1.0)
.animation(
.spring(response: 0.2, dampingFraction: 1),
value: configuration.isPressed
)