How to prevent Large Title from Collapsing

前端 未结 3 1620
小蘑菇
小蘑菇 2021-01-01 23:50

The question is simple, how can I prevent a Large Title Navigation Bar from collapse when a scrollview scrolls down?

My navigation must have a large navigation bar a

3条回答
  •  独厮守ぢ
    2021-01-01 23:59

    If someone arrives here from SwiftUI land, this is a good way to keep your lists in large title mode.

    // your content view ...
    
        var body: some View {
            VStack {
                PreventCollapseView()
                List {
                    ForEach(things, id: \.self) { thing in
                        Text(thing.name)
                    }
                }
            }
            .navigationBarTitle("All the things")
        }
    
    
    // end of view
    
    
    struct PreventCollapseView: View {
    
        private var mostlyClear = Color(UIColor(white: 0.0, alpha: 0.0005))
    
        var body: some View {
            Rectangle()
                .fill(mostlyClear)
                .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: 1)
        }
    }
    
    

提交回复
热议问题