Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // ContentView.swift
- //
- // Created by Desu Miko on 14.03.2021.
- //
- import SwiftUI
- struct ContentView: View {
- var body: some View {
- ZStack {
- Color.red.ignoresSafeArea(.all)
- NavigationView {
- ScrollView(.vertical, showsIndicators: false) {
- ForEach(1...100, id: \.self) { n in
- NavigationLink(destination: ChildView(value: "=> \(n)")) {
- Text("\(n)")
- .frame(width: 2100)
- }
- .navigationTitle("Hello")
- }
- .background(Color.red.ignoresSafeArea(.all))
- }
- }
- }
- }
- }
- struct ChildView: View {
- @Environment(\.presentationMode) var pm: Binding<PresentationMode>
- let value: String
- var body: some View {
- Text(value)
- .navigationBarHidden(true)
- .onTapGesture {
- pm.wrappedValue.dismiss()
- }
- }
- }
- extension UINavigationController: UIGestureRecognizerDelegate {
- override open func viewDidLoad() {
- super.viewDidLoad()
- interactivePopGestureRecognizer?.delegate = self
- UINavigationBar.appearance().barTintColor = UIColor(Color.green)
- }
- public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
- return viewControllers.count > 1
- }
- }
- struct ContentView_Previews: PreviewProvider {
- static var previews: some View {
- ContentView()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement