'How to change back button text in iPad in Swift UI?
Solution 1:[1]
You can create a custom view for the button
struct BackButton: View {
@Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>
var foregroundColor: Color
var body: some View {
Button(action: { presentationMode.wrappedValue.dismiss()}) {
HStack {
Image(systemName: Image.arrowLeft)
.foregroundColor(foregroundColor)
.aspectRatio(contentMode: .fit)
Text("the text you need")
.foregroundColor(foregroundColor)
}
}
}
}
after you can use it's some views:
@Environment(\.presentationMode) var presentationMode
var body: some View {
NavigationView {
ScrollView {
}.navigationBarItems(leading: BackButton(presentationMode: _presentationMode, foregroundColor: .whiteTextColor))
}
}
Also before you need delete default button, you can use it inside NavigationLink()
NavigationLink(destination: SomeView()
.navigationBarBackButtonHidden(true)
.navigationBarTitle("", displayMode: .inline)
.navigationBarHidden(true),
isActive: self.$isNext,
label: { EmptyView() })
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | sergio_veliz |


