Next Previous

SwiftUI List

70

List element in SwiftUI is an equivalent to UITableView in UIKit.

Static List

To create a static List, create List() element with a closure.

Add a few Text() elements in it.

import SwiftUI
struct ContentView: View {
    var body: some View {
         List() {
            Text("Cell 01")
            Text("Cell 02")
            Text("Cell 03")
        }
    }
}

Dynamic List

import SwiftUI

struct ContentView: View {
    var body: some View {
        List(0..<10) {_ in
            Text("")
        }
    }
}

This will show the empty cells on the List.

Sharing is caring!

Next Previous