Last active
September 16, 2023 19:40
-
-
Save xenodium/220005cdc1b0012868f9bdf8eebc1af0 to your computer and use it in GitHub Desktop.
blurred keyboard background
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ContentView: View { | |
var body: some View { | |
ZStack(alignment: .bottom) { | |
// ... | |
VisualEffectView(effect: UIBlurEffect(style: .systemUltraThinMaterial)) | |
.animation(.easeInOut) | |
.edgesIgnoringSafeArea(.all) | |
.onTapGesture { | |
UIApplication.shared.sendAction( | |
#selector(UIResponder.resignFirstResponder), | |
to: nil, | |
from: nil, | |
for: nil) | |
} | |
EditHabitView() | |
} | |
} | |
} | |
struct EditHabitView: View { | |
var body: some View { | |
VStack { | |
// ... | |
TextField( | |
"habit", | |
text: $title | |
) { _ in | |
// ... | |
} | |
// https://github.com/siteline/SwiftUI-Introspect.git | |
.introspectTextField { textField in | |
textField.returnKeyType = .done | |
textField.becomeFirstResponder() | |
} | |
} | |
} | |
} | |
struct VisualEffectView: UIViewRepresentable { | |
var effect: UIVisualEffect? | |
func makeUIView(context: UIViewRepresentableContext<Self>) -> UIVisualEffectView { | |
UIVisualEffectView() | |
} | |
func updateUIView(_ uiView: UIVisualEffectView, context: UIViewRepresentableContext<Self>) { | |
uiView.effect = effect | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment