美文网首页
SwiftUI 界面跳转(push)

SwiftUI 界面跳转(push)

作者: 小凡凡520 | 来源:发表于2019-10-18 15:46 被阅读0次
    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()
        }
    }
    

    相关文章

      网友评论

          本文标题:SwiftUI 界面跳转(push)

          本文链接:https://www.haomeiwen.com/subject/utaimctx.html