Change background color of View inside TabView having NavigationView and ScrollView in SwiftUI

后端 未结 1 1442
梦谈多话
梦谈多话 2021-01-24 06:43

I want to build a TabView with 4 tabs having collection views in it. Below is my code of one tab named \'Gallery\'.

         


        
1条回答
  •  有刺的猬
    2021-01-24 06:52

    Here is possible approach (scroll view is not broken in such case)

    NavigationView {
        GeometryReader { gp in
            ScrollView {
                ZStack(alignment: .top) {
                    Rectangle().fill(Color.red) // << background
    
                  // ... your content here, internal alignment might be needed
    
                }.frame(minHeight: gp.size.height)
    
            }
            .navigationBarTitle("Gallery")
        }
    }
    

    0 讨论(0)
提交回复
热议问题