Advertisement
Guest User

Untitled

a guest
Mar 13th, 2021
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.55 KB | None | 0 0
  1. //
  2. //  ContentView.swift
  3. //
  4. //  Created by Desu Miko on 14.03.2021.
  5. //
  6.  
  7. import SwiftUI
  8.  
  9. struct ContentView: View {
  10.     var body: some View {
  11.         ZStack {
  12.             Color.red.ignoresSafeArea(.all)
  13.            
  14.             NavigationView {
  15.                 ScrollView(.vertical, showsIndicators: false) {
  16.                     ForEach(1...100, id: \.self) { n in
  17.                         NavigationLink(destination: ChildView(value: "=> \(n)")) {
  18.                             Text("\(n)")
  19.                                 .frame(width: 2100)
  20.                         }
  21.                         .navigationTitle("Hello")
  22.                     }
  23.                     .background(Color.red.ignoresSafeArea(.all))
  24.  
  25.                 }
  26.             }
  27.         }
  28.     }
  29. }
  30.  
  31. struct ChildView: View {
  32.     @Environment(\.presentationMode) var pm: Binding<PresentationMode>
  33.    
  34.     let value: String
  35.     var body: some View {
  36.         Text(value)
  37.             .navigationBarHidden(true)
  38.             .onTapGesture {
  39.                 pm.wrappedValue.dismiss()
  40.             }
  41.     }
  42. }
  43.  
  44. extension UINavigationController: UIGestureRecognizerDelegate {
  45.     override open func viewDidLoad() {
  46.         super.viewDidLoad()
  47.         interactivePopGestureRecognizer?.delegate = self
  48.         UINavigationBar.appearance().barTintColor = UIColor(Color.green)
  49.     }
  50.    
  51.     public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
  52.         return viewControllers.count > 1
  53.     }
  54. }
  55.  
  56.  
  57. struct ContentView_Previews: PreviewProvider {
  58.     static var previews: some View {
  59.         ContentView()
  60.     }
  61. }
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement