title: Array of Custom Views in SwiftUI for using in ForEach
body: <p>I have 4 similar views, like <code>SettingsPointOneView()</code> for each point in figure. They store 2 views <code>SliderFirstPointX()</code> and <code>SliderFirstPointY()</code> in this case. They (SliderFirstPointX etc...)control and change values of axis(x,y) for particular point of custom figure, with sliders.</p>
  <p>How it looks：</p>
  <p><a href="https://i.stack.imgur.com/Yylv1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Yylv1.png" alt="enter image description here" /></a></p>
  <p><strong>SliderFirstPointX() and SliderFirstPointY()</strong></p>
  <pre><code>struct SliderFirstPointX: View{
  @EnvironmentObject var geometryBuilder : GeometryBuilderViewModel
  var body: some View{
      VStack{
          Text(&quot;Point one: X&quot;)
          Text(&quot;\(Int(geometryBuilder[0].x))&quot;)
              .foregroundColor(.gray)
              .opacity(0.5)
          Slider(value: $geometryBuilder[0].x, in: 10...380)
              .accentColor(.orange)
              .padding(3)
      }
  }
  }
  
  
  struct SliderFirstPointY: View{
  @EnvironmentObject var geometryBuilder: GeometryBuilderViewModel
  var body: some View{
      VStack{
          Text(&quot;Point one: Y&quot;)
          Text(&quot;\(Int(geometryBuilder[0].y))&quot;)
              .foregroundColor(.gray)
              .opacity(0.5)
          Slider(value: $geometryBuilder[0].y, in: 0...380)
              .accentColor(.orange)
              .padding(3)
      }
  }
  }
  </code></pre>
  <p><strong>SettingsPointOneView()</strong></p>
  <pre><code>struct SettingsPointOneView: View{
  var body: some View{
      ZStack{
          RoundedRectangle(cornerRadius: 10)
              .stroke()
              .frame(width: 360, height: 150, alignment: .leading)
  
          HStack{
              SliderFirstPointX()
              SliderFirstPointY()
          }.padding([.leading, .trailing], 50)
      }
  }
  }
  </code></pre>
  <p>I'd wanted to position them into LazyVGrid, similar how it is on screenshot. So I've created constant var and tried to initialize it like:</p>
  <pre><code>let arrayOfViews: [Any] = [SettingsPointOneView(), SettingsPointTwoView(), SettingsPointThreeView(), SettingsPointFoutView()]
  </code></pre>
  <p><strong>After that, several error messages occurred, that I don't how to work with:</strong></p>
  <p><strong>In front of ForEach:</strong>
  <em>• Protocol 'Any' as a type cannot conform to 'AccessibilityRotorContent</em></p>
  <p><strong>In front of LazyVGrid:</strong></p>
  <p><em>• Generic struct 'LazyVGrid' requires that 'some AccessibilityRotorContent' conform to 'View';</em></p>
  <p><em>• Initializer 'init(columns:alignment:spacing:pinnedViews:content:)' requires that 'some AccessibilityRotorContent' conform to 'View';</em></p>
  <p><em>• Struct 'ViewBuilder' requires that 'some AccessibilityRotorContent' conform to 'View'</em></p>
  <p>Because I hadn't found remedy, I had to use this implementation, but it's not satisfy me:</p>
  <pre><code>struct ContentView: View {
  
  ...some code...
  
  let first = [SettingsPointOneView()]
  let second = [SettingsPointTwoView()]
  let third = [SettingsPointThreeView()]
  let fourth = [SettingsPointFourView()]
       var body: some View {
  
        ..some code...
  
         ScrollView{
              LazyVGrid(columns: [GridItem(.flexible(minimum: 100, maximum: 200))]){
                  ForEach(0...0, id: \.self){
                      first[$0].padding(.top)
                      second[$0]
                      third[$0]
                      fourth[$0]
                  }
          }
  
  ..some code...
  
         }
  </code></pre>
  <p>This solution works pretty well, although I guess this is wrong way to implement this feature.</p>
  <p><strong>Is there any way to use approach with array of Views in ForEach?</strong></p>
  <p><em>Truth be told, I've been programming for 3 months, so I'll appreciate any advice about what I should learn as Swift developer.</em></p>