Skip to content

Instantly share code, notes, and snippets.

@prafullakumar
Last active June 24, 2020 11:49
Show Gist options
  • Save prafullakumar/2afb8236c93527b08693cd598f75db68 to your computer and use it in GitHub Desktop.
Save prafullakumar/2afb8236c93527b08693cd598f75db68 to your computer and use it in GitHub Desktop.
import SwiftUI
struct Row {
var value: Int
init(value: Int) {
print("INIT: \(value)") // see init calls with scroll in case of lazy loading
self.value = value
}
}
struct ContentView: View {
var body: some View {
NavigationView {
ScrollView(.vertical){ //.horizontal for Horizontal scaoll
LazyVStack(alignment: .leading) { //LazyHStack for Horizontal layout
ForEach(1...50, id: \.self) { i in
Text("Row: \(Row(value: i).value)").padding(.all, 10)
}
}
}.navigationTitle("Demo Objects")
}
}
}
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