# SwiftUI + NavigationBar + Detail's nav bar hidden on iOS 13.XX but not on iOS 14.YY

**URL:** <https://forums.kodeco.com/t/swiftui-navigationbar-details-nav-bar-hidden-on-ios-13-xx-but-not-on-ios-14-yy/128405>\
**Category:** iOS\
**Created:** [December 24, 2020, 4:33am UTC](https://forums.kodeco.com/t/swiftui-navigationbar-details-nav-bar-hidden-on-ios-13-xx-but-not-on-ios-14-yy/128405 "2020-12-24T04:33:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lganti](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/lganti/32/103565_2.png) [@lganti](https://forums.kodeco.com/u/lganti)\
**Post date:** [December 24, 2020, 4:33am UTC](https://forums.kodeco.com/t/swiftui-navigationbar-details-nav-bar-hidden-on-ios-13-xx-but-not-on-ios-14-yy/128405/1 "2020-12-24T04:33:21Z")

</div>

**Is there a way to be selective about what entails .onDisappear? E.g. not involve scrolling?**

```
// The navigation bar hiding is being done like so
struct UserProfileView: View {
  var body: some View {
    @Published var hideBar = true
    
    NavigationView {
      ZStack {
        List {
          Section(header: Text(NSLocalizedString("My Routes", comment: ""))) {
            MyRoutesSectionView(hideBar: self.$hideBar, selectedView: self.$selectedView)
          }
        }
        
        VStack {
          
        }
      }
      .navigationTitle("")
      .navigationBarHidden(self.hideBar)
    }
  }
}

struct MyRoutesSectionView: View {
  var body: some View {
    @Binding var hideBar = true
    
    NavigationLink(destination: modifiedView, tag: tag, selection: self.$selectedView) {
      MyRoutesNavigationLinkView(myRoutesObject: object)
    }.onDisappear {
      if #available(iOS 14, *) {
        // redundant --- just have it here to make it clear
        // the actual problem being --- navbar is hidden in detail on iOS 13.5
        self.hideBar = true
      } else {
        // this will not hide the navbar in the detail view but upon scrolling
        // the `UserProfileView` . . . when the section disappears . . . navbar would appear
        self.hideBar = false
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![lganti](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/lganti/32/103565_2.png) [@lganti](https://forums.kodeco.com/u/lganti)\
**Post date:** [December 25, 2020, 9:36am UTC](https://forums.kodeco.com/t/swiftui-navigationbar-details-nav-bar-hidden-on-ios-13-xx-but-not-on-ios-14-yy/128405/2 "2020-12-25T09:36:41Z")

</div>

using a GeometryReader and anchors, let’s see how this goes

---

<div class="post-metadata">

**Author:** ![lganti](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/lganti/32/103565_2.png) [@lganti](https://forums.kodeco.com/u/lganti)\
**Post date:** [December 27, 2020, 9:19am UTC](https://forums.kodeco.com/t/swiftui-navigationbar-details-nav-bar-hidden-on-ios-13-xx-but-not-on-ios-14-yy/128405/3 "2020-12-27T09:19:49Z")

</div>

**a geometry proxy is merging all the navigation links into one though I am not using it to set any entity’s size anywhere, WUT 😕**

```
struct MyRoutesSectionView: View {
 @Binding var hideBar: Bool
 @Binding var parentVerticalContentOffSet: CGFloat

 var body: some View {
  // This geometry proxy is merging all the navigation links into one though I am not using it to set any entity's size anywhere, WUT :/ 
  GeometryReader { proxy in
   ForEach(Destination.allCases, id: \.self) { destination in
    .
    .
    .
    NavigationLink(destination: modifiedView, tag: tag, selection: self.$selectedView) {
     MyRoutesNavigationLinkView(myRoutesObject: object)
    }.onDisappear {
     if #available(iOS 14, *) {
      self.hideBar = true
     } else {
      let selfHeight = proxy.frame(in: CoordinateSpace.local).size.height
      if parentVerticalContentOffSet >= selfHeight {
       self.hideBar = true
      } else {
       self.hideBar = false
      }
     }
    }
   }
  }
 }
}

// Parent View
struct UserProfileView: View {
  @ObservedObject private(set) var store = UserProfileStore()
  @State private var myRoutesSectionVerticalOffset: CGFloat = 0

  var body: some View {
    NavigationView {
      GeometryReader { proxy in
        ZStack {
          List {
            GeometryReader { geometry in
              Rectangle()
        
            }
            
            Section(header: Text(NSLocalizedString("My Routes", comment: ""))) {
              MyRoutesSectionView(hideBar: $store.hideBar,
                                  parentVerticalContentOffSet: self.$myRoutesSectionVerticalOffset,
                                  selectedView: self.$selectedView)
                .transformAnchorPreference(key: BMBoundsKey.self, value: .bounds) {
                  $0.append(BMBounds(id: "MyRoutesSectionView", bounds: proxy[$1]))
                }
                .onPreferenceChange(BMBoundsKey.self) { preference in
                  if let bmBounds = preference.last {
                    self.myRoutesSectionVerticalOffset = bmBounds.bounds.origin.y
                  }
                }
            }
          }
          .edgesIgnoringSafeArea(.all)
          .listStyle(GroupedListStyle())
          
          VStack {
            
          }
        }
        .edgesIgnoringSafeArea(.all)
        .navigationBarTitle("")
        .navigationBarHidden(store.hideBar)
        .onAppear {
          store.hideBar = true
        }
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![system](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@system](https://forums.kodeco.com/u/system)\
**Post date:** [June 8, 2021, 8:33pm UTC](https://forums.kodeco.com/t/swiftui-navigationbar-details-nav-bar-hidden-on-ios-13-xx-but-not-on-ios-14-yy/128405/4 "2021-06-08T20:33:28Z")

</div>

This topic was automatically closed after 166 days. New replies are no longer allowed.
