[Memo] VStackに大量のViewを表示するアプローチ その2

Updated
Oct 5, 2019 9:02 AM
Created
Oct 5, 2019 8:23 AM
Tags
SwiftUI.frameworkMemo
Keywords
let items: [Item] 

VStack {
  ForEach(items.indices) { index in
    let item = items[index]
    return ...
  }
}

Extension to use easily

extension ForEach where Data == Range<Int>, ID == Int, Content : View {
  
  init<Item>(items: [Item], @ViewBuilder body: @escaping (Item) -> Content) {
    self = ForEach(items.indices) { index in
      body(items[index])
    }
  }

}