18:SwiftUI-Section

发布时间 2023-03-28 16:23:59作者: 风zk

 

 

正文

//
//  SectionPage.swift
//  SwiftUIDeom
//
//  Created by zhoukang03 on 2023/3/28.
//

import SwiftUI

struct SectionPage : View {
    var body: some View {
        
        VStack {
            List {
                Section(header: Text("I'm header"), footer: Text("I'm footer")) {
                    ForEach(0..<8) {
                        Text("Hello \($0)")
                    }
                }
                Section(header: Text("I'm header 2"), footer: Text("I'm footer 2")) {
                    ForEach(16..<30) {
                        Text("Hello \($0)").bold()
                    }
                }
            }
            .listStyle(.grouped)
            .background(Color.white)
            
            Button(action: {
                print("Tap")
            }) {
                Text("SwiftUI")
                    .foregroundColor(.white)
                    .frame(width: UIScreen.main.bounds.width - 30,height: 45)
            }
            .background(Color.orange)
            .cornerRadius(5)

        }
        .background(Color.white)
        .navigationBarTitle(Text("Section"))
        
    }
}

#if DEBUG
struct SectionPage_Previews : PreviewProvider {
    static var previews: some View {
        SectionPage()
    }
}
#endif

 

示例图