I have a search bar view, when the view is Expanding, the magnifying glass will appear as a shadow. How can I remove this?
ToolbarItem(placement: .automatic) {
HStack {
if self.showSearchBar {
HStack {
Image(systemName: "magnifyingglass") // I think that here is the problem, I need to add some transition, or remove it?
let mytxtfield = TextField("Search in menu", text: self.$txtSearch)
if #available(iOS 15, *) {
mytxtfield.submitLabel(.search)
}
Button {
self.txtSearch = ""
UIApplication.shared.endEditing()
withAnimation(.spring(response: 0.30, dampingFraction: 0.3, blendDuration: 0)){
self.showSearchBar.toggle()
}
} label: {
Image(systemName: "xmark")
}
}
.padding(self.showSearchBar ? 10 : 0)
.background(colorScheme == .dark ? Color(.secondarySystemBackground) : Color.white)
.cornerRadius(20)
.frame(width: 320, height: 45)
.transition(.move(edge: .trailing))
} else {
Button {
withAnimation(.spring(response: 0.45, dampingFraction: 0.60, blendDuration: 0)){
self.showSearchBar.toggle()
}
} label: {
Image(systemName: "magnifyingglass") // the problem is here///// this image gets to the left somehow when the animation happens
}
.transition(.move(edge: .trailing))
}
}
}
I uploaded the video of the animation here: https://files.fm/u/mpzr7zytn
The photo of the glitch: https://files.fm/u/sndev9jzc
Somehow the magnifying glass appears first.