Section
SwiftUI ro‘yxatlar va formalar: Section
Ro‘yxatlardagi qatorlarni va formalardagi kiritish maydonlarini ixtiyoriy sarlavha (header) va pastki qism (footer) bilan Section yordamida guruhlang.
Misol: List ichidagi bo‘limlar
Misol
import SwiftUI
struct SectionListDemo: View {
var body: some View {
List {
Section(header: Text("Fruits"), footer: Text("End Fruits")) {
Text("Apple"); Text("Banana")
}
Section(header: Text("Veggies")) { Text("Carrot") }
}
}
}
import SwiftUI
struct ContentView: View { var body: some View { SectionListDemo() } }
import SwiftUI
@main
struct MyApp: App { var body: some Scene { WindowGroup { ContentView() } } }
Misol: Form ichidagi bo‘limlar
Misol
import SwiftUI
struct SectionFormDemo: View {
@State private var name = ""
@State private var notifications = true
var body: some View {
Form {
Section(header: Text("Profile"), footer: Text("Shown to others")) {
TextField("Name", text: $name)
}
Section(header: Text("Preferences")) {
Toggle("Notifications", isOn: $notifications)
}
}
}
}
import SwiftUI
struct ContentView: View { var body: some View { SectionFormDemo() } }
import SwiftUI
@main
struct MyApp: App { var body: some Scene { WindowGroup { ContentView() } } }
W3Schools Pathfinder
Yutuqlaringizni kuzating – bu bepul!
