Skip to content

Commit

Permalink
✨ View+endEditingOnTap
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasackee committed Dec 6, 2024
1 parent 336fe80 commit a42d6d5
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Sources/ACKategories/SwiftUIExtensions/View+endEditingOnTap.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import SwiftUI

@available(iOS 13.0, *)
public extension View {

@available(iOSApplicationExtension, unavailable)
func endEditingOnTap(
_ action: (() -> Void)? = nil
) -> some View {
onTapGesture {
UIApplication.shared.sendAction(
#selector(UIResponder.resignFirstResponder),
to: nil,
from: nil,
for: nil
)
action?()
}
}
}

0 comments on commit a42d6d5

Please sign in to comment.