Hello,
I need help because I don't know how to change the color of cancel title button at the trailing of the search bar with SwiftUI.
NavigationView {
ZStack {
// ScrollView and other content
}
.navigationTitle("SuperNews SwiftUI")
.navigationBarTitleDisplayMode(.inline)
.toolbarBackground(.visible, for: .navigationBar)
.toolbarBackground(Color("SuperNewsDarkBlue"), for: .navigationBar)
.background(LinearGradient(gradient: Gradient(colors: [Color("SuperNewsBlue"), Color("SuperNewsDarkBlue"), Color("SuperNewsDarkBlue"), Color("SuperNewsDarkBlue"), .black]), startPoint: .top, endPoint: .bottom))
}
With UIKit, I know how to do it:
// Setting cancel button title
UIBarButtonItem.appearance(whenContainedInInstancesOf: [UISearchBar.self]).title = "Annuler"
// Setting cancel button title color
UIBarButtonItem.appearance(whenContainedInInstancesOf: [UISearchBar.self]).tintColor = .label
Can you help me please ? I don't know how to do it ?
Thanks.