PressableIconButtonStyle.swift 392 B

1234567891011
  1. import SwiftUI
  2. struct PressableIconButtonStyle: ButtonStyle {
  3. func makeBody(configuration: Configuration) -> some View {
  4. configuration.label
  5. .background(Color.clear)
  6. .opacity(configuration.isPressed ? 0.3 : 1.0) // Change opacity when pressed
  7. .animation(.easeInOut(duration: 0.25), value: configuration.isPressed) // Smooth transition
  8. }
  9. }