18:SwiftUI-Section

 

 

正文

//
//  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

 

示例图

 

posted on 2023-03-28 16:16  风zk  阅读(169)  评论(0编辑  收藏  举报

导航