Fix: Navigation Bar Hairline and Missing Soft Edge in Paged ScrollView

Fix: Navigation Bar Hairline and Missing Soft Edge in Paged ScrollView

Written by

in

Quick answer: In iOS 26/27 the outer horizontal paging ScrollView becomes the bar’s tracked scroll view, so the inner vertical pages never drive the navigation bar or bottom toolbar effects. Wrap the pager in a GeometryReader, apply .ignoresSafeArea(edges: .vertical) to the horizontal ScrollView and re-add the insets with .safeAreaPadding on each page, then set .scrollEdgeEffectStyle on the outer pager.

Why this happens

On iOS 26 and 27 SwiftUI added scrollEdgeEffectStyle and the Liquid Glass bar materials. The navigation bar and bottom toolbar watch the nearest UIScrollView that is registered as the view controller’s contentScrollView to decide when to show a scroll edge effect.

A single vertical ScrollView works as expected: at rest the bars are clear, when content scrolls under the navigation bar the standard effect appears, and a .soft style appears at the bottom when you set .scrollEdgeEffectStyle(.soft, for: .bottom).

When you put those vertical ScrollViews inside a horizontal paging ScrollView with .scrollTargetBehavior(.paging) and .containerRelativeFrame(.horizontal), the outer horizontal scroll view is the one the system tracks. The inner vertical scroll views scroll, but the bars do not observe them. The result is two symptoms:

  • Top bar shows its scroll edge effect immediately at rest — on iOS 27 this is a tinted band with a hairline divider, even though nothing has scrolled under it.
  • Bottom toolbar never shows the .soft effect you set on the page.

This is why hiding effects on the pager alone does not help. If you set .scrollEdgeEffectHidden(true, for: .vertical) on the horizontal pager, the hairline at rest goes away, but the pages’ effects still never appear. The same happens with TabView(.page) and with a UIKit pager using UICollectionView + UIHostingController and setContentScrollView(_:for:) — the bars stay attached to the outer pager.

How to fix it

1. Make the bars follow the visible vertical page

The workaround that restores the single-page behavior is to take the outer pager out of the safe area and then pad each page back in. The bars then derive their edge effects from the outer pager, but the outer pager’s content inset now matches the vertical pages, so the effects appear at the correct scroll offsets.

This only works if you ignore .vertical edges, not just .bottom. Ignoring only .bottom is not sufficient.

Wrap the horizontal ScrollView in a GeometryReader to read the safe area insets, ignore vertical safe area on the pager, and add the insets back to each page with safeAreaPadding. Apply the desired scrollEdgeEffectStyle to the outer pager, not to the inner pages.

import SwiftUI

struct PagerScreen: View {
    var body: some View {
        GeometryReader { geo in
            ScrollView(.horizontal) {
                LazyHStack(spacing: 0) {
                    ForEach(1...5, id: \.self) { number in
                        LongPage(number: number)
                            .containerRelativeFrame(.horizontal)
                            .safeAreaPadding(.top, geo.safeAreaInsets.top)
                            .safeAreaPadding(.bottom, geo.safeAreaInsets.bottom)
                    }
                }
                .scrollTargetLayout()
            }
            .scrollTargetBehavior(.paging)
            .scrollIndicators(.hidden)
            .ignoresSafeArea(edges: .vertical)
            .scrollEdgeEffectStyle(.soft, for: .bottom)
        }
        .navigationTitle("Pager")
        .navigationBarTitleDisplayMode(.inline)
        .toolbar { BarItems() }
    }
}

struct LongPage: View {
    let number: Int
    var body: some View {
        ScrollView {
            Text(String(repeating: "Page \(number). The quick brown fox jumps over the lazy dog. ", count: 60))
                .padding()
        }
        // Do not set scrollEdgeEffectStyle here when using the workaround.
        // Set it on the outer pager instead.
    }
}

Steps:

  1. Put a GeometryReader around the horizontal ScrollView.
  2. Add .ignoresSafeArea(edges: .vertical) to the horizontal ScrollView.
  3. On each page view inside the LazyHStack, add .safeAreaPadding(.top, geo.safeAreaInsets.top) and .safeAreaPadding(.bottom, geo.safeAreaInsets.bottom).
  4. Move .scrollEdgeEffectStyle(.soft, for: .bottom) from LongPage to the outer horizontal ScrollView.

After this, the bottom soft edge appears when the visible vertical page is scrolled, and the pager no longer shows a solid bar at rest on iOS 26.

2. Fix the iOS 27 top hairline at rest

The top hairline at rest is an iOS 27 change to the default .automatic edge effect. The workaround in step 1 fixes the bottom, but on iOS 27 you will still see the hairline unless you also address the top.

Simplest option is to force a soft effect for the top as well:

GeometryReader { geo in
    ScrollView(.horizontal) {
        // ... pages as above
    }
    .scrollTargetBehavior(.paging)
    .scrollIndicators(.hidden)
    .ignoresSafeArea(edges: .vertical)
    .scrollEdgeEffectStyle(.soft, for: .vertical) // top and bottom both soft
}

This suppresses the hairline. The bar stays soft at rest and stays soft when scrolled, which is often acceptable for a pager.

If you want the exact single-page behavior — clear at rest, automatic material once content scrolls under the bar — toggle the top style based on whether the visible page is scrolled:

struct PagerScreen: View {
    @State private var isContentScrolled = false

    var body: some View {
        GeometryReader { geo in
            ScrollView(.horizontal) {
                LazyHStack(spacing: 0) {
                    ForEach(1...5, id: \.self) { number in
                        LongPage(number: number)
                            .containerRelativeFrame(.horizontal)
                            .safeAreaPadding(.top, geo.safeAreaInsets.top)
                            .safeAreaPadding(.bottom, geo.safeAreaInsets.bottom)
                            .onScrollGeometryChange(for: Bool.self) { proxy in
                                proxy.contentOffset.y + proxy.contentInsets.top > 0
                            } action: { _, isScrolled in
                                isContentScrolled = isScrolled
                            }
                    }
                }
                .scrollTargetLayout()
            }
            .scrollTargetBehavior(.paging)
            .scrollIndicators(.hidden)
            .ignoresSafeArea(edges: .vertical)
            .scrollEdgeEffectStyle(isContentScrolled ? .automatic : .soft, for: .top)
            .scrollEdgeEffectStyle(.soft, for: .bottom)
        }
        .navigationTitle("Pager")
        .navigationBarTitleDisplayMode(.inline)
        .toolbar { BarItems() }
    }
}

onScrollGeometryChange reports true once the vertical content offset moves past the top inset. When isContentScrolled is false the top uses .soft (no hairline), when true it switches to .automatic so you get the standard material as content passes under the bar.

Note: the flag can stick when you page horizontally between two nested pages that have different scroll positions. If you see the top style not updating after a swipe, store scroll state per page and update the shared flag on page change. For example, keep a @State var scrolledByPage: [Int: Bool] and on horizontal scroll target change, set isContentScrolled = scrolledByPage[currentPage] ?? false.

3. What does not work

  • .scrollEdgeEffectHidden(true, for: .vertical) on the pager plus .scrollEdgeEffectHidden(false, for: .vertical) on each page removes the band at rest but the pages’ effects never appear.
  • TabView with .tabViewStyle(.page) shows solid bars for both top and bottom.
  • UIKit pager with setContentScrollView(_:for: .top) and .bottom on the navigation controller’s top view controller correctly reports the page’s scroll view via contentScrollView(for:), but the bars still do not react. Hiding the collection view’s topEdgeEffect / bottomEdgeEffect again only removes the band at rest.

These approaches fail for the same reason: the system continues to track the outer paging scroll view for edge effects.

How to prevent it

  • Keep one scroll view driving the bars. If you need paging, use the GeometryReader + ignoresSafeArea(.vertical) + safeAreaPadding pattern from the start.
  • Apply scrollEdgeEffectStyle to the outer paging ScrollView, not to the inner vertical pages, when pages are nested.
  • Test on iOS 27 specifically for the top hairline. The bottom issue reproduces on iOS 26 and 27, the top hairline only on iOS 27.
  • If you toggle between .soft and .automatic, drive it from onScrollGeometryChange on the visible page and also update on page change.
  • Avoid mixing TabView(.page) with bar edge effects if you need per-page vertical effects — use ScrollView(.horizontal) with scrollTargetBehavior(.paging) instead.

FAQ

Why does .scrollEdgeEffectHidden not fix the pager?

Hiding the outer pager’s vertical edge effect removes the incorrect band at rest, but it does not re-attach the bars to the inner vertical scroll views. The bars still track the outer pager, so the inner pages never trigger an effect.

Do I need GeometryReader?

Yes for this workaround. You need the actual top and bottom safe area insets to re-apply with safeAreaPadding after calling ignoresSafeArea(edges: .vertical). Using a fixed padding value will be wrong on devices with different notch/Dynamic Island or toolbar heights.

Will this work with NavigationStack and toolbar(.bottomBar)?

Yes. The example uses NavigationStack with .toolbar { ToolbarItemGroup(placement: .bottomBar) }. The outer pager’s scrollEdgeEffectStyle(.soft, for: .bottom) controls the bottom toolbar, and the top style controls the navigation bar. Keep both modifiers on the outer horizontal ScrollView inside the GeometryReader.

Sources & credits

Parts of this guide are adapted from content licensed under CC BY-SA 4.0; this article is shared under the same license.