Reputation: 1037
I am developing an application UI with Swift UI, and I would like to remove Back button
from Navigationbar
from whole app. is there any way to remove Back Button
.
Upvotes: 0
Views: 1082
Reputation: 82759
your code is fine and correct, for example you get the step by step implemntation from SwiftUI Developer portal
import SwiftUI
struct ContentView : View {
var body: some View {
VStack {
Text("Target Color Block")
Text("Target Color Block")
Button(action: {
/* handle button action here */ })
{
Text("your Button Name")
.color(.white)
.padding(10)
.background(Color.blue)
.cornerRadius(5)
.shadow(radius: 5)
.clipShape(RoundedRectangle(cornerRadius: 5))
}
}
}
}
#if DEBUG
struct ContentView_Previews : PreviewProvider {
static var previews: some View {
ContentView()
}
}
#endif
Upvotes: 1
Reputation: 4490
It's clearly written in the documentation of SwiftUI of how to use it. Also suggest you to watch the Introducing SwiftUI talk from this year WWDC.
struct ContentView : View {
var body: some View {
Button(action: { self.action() }) {
Text("Button Text")
}
}
private func action() {
print("Do magic")
}
}
Upvotes: 0
Reputation: 77621
You need to start with some SwiftUI tutorials.
SwiftUI is a complete change from UIKit and so buttons no longer have target/actions.
To add a button you can use...
Button(action: { /* Do something here */ }) {
Text("Press me")
}
Upvotes: 0