push
// TextView
struct TextView: View {
var body: some View {
NavigationView {
NavigationLink(destination: CircleImage(), label: {
Text("push")
})
.navigationBarTitle(Text("mark"))
}
}
}
struct TextView_Preview: PreviewProvider {
static var previews: some View {
TextView()
}
}
// CircleImage
struct CircleImage: View {
@State var value:CGFloat = 0.5
var body: some View {
VStack {
Slider(value: $value)
}
}
}
struct CircleImage_Preview: PreviewProvider {
static var previews: some View {
CircleImage()
}
}
struct PageView: View {
private let messages = [
"Hello",
"How are you?"
]
var body: some View {
NavigationView {
List(messages, id: \.self, rowContent: { me in
NavigationLink(destination: DetailsView(message: me)) {
Text(me)
}
})
.navigationBarTitle("Messages")
}
}
}
struct DetailsView: View {
let message: String
var body: some View {
VStack {
Text(message)
.font(.largeTitle)
}
}
}
struct PageView_Preview: PreviewProvider {
static var previews: some View {
PageView()
}
}
struct PageView: View {
@State var selection: Int? = nil
var body: some View {
NavigationView {
VStack {
NavigationLink(destination: Details(), tag: 1, selection: $selection) {
Button("Press me") {
self.selection = 1
}
}
}
}
}
}
struct Details: View {
@Environment(\.presentationMode) var presentation
var body: some View {
Group {
Text("Details")
Button("pop back") {
self.presentation.wrappedValue.dismiss()
}
}
}
}
struct PageView_Preview: PreviewProvider {
static var previews: some View {
PageView()
}
}
网友评论