Я пытаюсь скрыть панель поиска в своем приложении, как Apple сделала это в своем приложении сообщений:
Я уже реализовал UISearchBar в SwiftUI:
struct SearchBar: UIViewRepresentable {
@Binding var text: String
class Coordinator: NSObject, UISearchBarDelegate {
@Binding var text: String
init(text: Binding<String>) {
_text = text
}
func searchBar(_: UISearchBar, textDidChange searchText: String) {
text = searchText
}
}
func makeCoordinator() -> SearchBar.Coordinator {
return Coordinator(text: $text)
}
func makeUIView(context: UIViewRepresentableContext<SearchBar>) -> UISearchBar {
let searchBar = UISearchBar(frame: .zero)
searchBar.delegate = context.coordinator
searchBar.searchBarStyle = .minimal
searchBar.placeholder = "Поиск по названию, дедлайну или описанию"
return searchBar
}
func updateUIView(_ uiView: UISearchBar, context _: UIViewRepresentableContext<SearchBar>) {
uiView.text = text
}
}
Как реализовать анимацию скрытия и скрытия в SwiftUI?