Back button messed with content on a detail view

Viewed 28

I have items on a list. Every item is a NavigationLink that, once clicked, calls this:

import SwiftUI

struct ItemDetail: View {
  private var item:MyItem

  var body: some View {
    ScrollView {
      Text (item.fullDescription)
       .fixedSize(horizontal: false, vertical: true)
       .frame(alignment:.leading)
       .padding([.leading, .trailing], 10)
  }
}

Descriptions can be long. So, when I scroll the description up to read all content, the content gets over the back button, horribly, like this:

enter image description here

How do I solve that? Is there any way to make the navigation bar opaque?

1 Answers

I am unable to replicate this, but as long as you are using the correct navigation tree it should work as intended. Please see the code below for a simple example.

    //
    //  ContentView.swift
    //  Tester
    //
    //  Created by Jarren Campos on 3/15/22.
    //

import SwiftUI

struct ContentView: View {
    var body: some View{
        NavigationView{
            VStack{
                NavigationLink(destination: ItemDetail()) {
                    Text("To new view")
                }
            }
        }
    }
}

struct ItemDetail: View {
    var body: some View {
        ScrollView {
            Text ("slkdjf dksljf klsdj fklsdjf klsdj fklsdj fklsdjfklsd jfklsdj fklsdjfklsdjfkldjfkldjfkldjfkldjfkldjfkld jfkldjfkdljfkdlfjkdlfjkdfjdkfj kdjfkdjfkdjfkdjfkdjfdkjfkdfjdkfjdfjdkfj")
                .fixedSize(horizontal: false, vertical: true)
                .frame(alignment:.leading)
                .padding([.leading, .trailing], 10)
        }
    }
}
Related