article

Friday, August 13, 2021

SwiftUI Header and Footer List

SwiftUI Header and Footer List
ContentView.swift
 
//
//  ContentView.swift
//  swiftuidev
//
//  Created by Cairocoders
//

import SwiftUI

struct ContentView: View {
    let toyota = ["Corolla","Camry","Yaris"]
    let honda = ["HR-V","Odyssey","Mobelio"]
    
    var body: some View {
        NavigationView {
            List {
                Section(header:
                    Text("Toyota")) {
                        ForEach(0 ..< toyota.count) {
                            Text(self.toyota[$0])
                        }
                    }
                Section(header:
                    HStack {
                        Image(systemName: "car")
                        Text("Honda")
                    }
                , footer: Text("This is a example list of a few car brands").font(.footnote))  {
                               ForEach(0 ..< honda.count) {
                                   Text(self.honda[$0])
                               }
                           }
            
            } .navigationBarTitle("Cars")
        }
           
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Related Post