-
-
Save anupamchugh/8591adfb1bb300df0c62ed132ac7ca0e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ContentView: View { | |
var myData = Array(1...10).map{"\($0)"} | |
var column = Array(repeating: GridItem(.flexible(), spacing: 10), count: 3) | |
var body: some View { | |
VStack{ | |
ScrollView { | |
LazyVGrid(columns: column, spacing: 10){ | |
Section(header: Text("Header Without Pin").background(Color.yellow)){ | |
ForEach(self.myData, id: \.self){ data in | |
Text(data).padding() | |
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 50) | |
.background(Color.red) | |
} | |
} | |
} | |
} | |
ScrollView { | |
LazyVGrid(columns: column, spacing: 10, pinnedViews: [.sectionHeaders]){ | |
Section(header: Text("Header With Pin").background(Color.yellow) | |
.frame(minWidth:0, maxWidth: .infinity)){ | |
ForEach(self.myData, id: \.self){ data in | |
Text(data).padding() | |
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 50) | |
.background(Color.green) | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
struct ContentView_Previews: PreviewProvider { | |
static var previews: some View { | |
ContentView() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment