[SUI] 양식 (Form)

발행: (2026년 1월 31일 오전 06:42 GMT+9)
2 min read
원문: Dev.to

Source: Dev.to

Form

Form은 주로 기능 설정에 사용되는 컨트롤을 그룹화하는 컨테이너입니다.
컨트롤을 grouped 스타일의 List에 표시하고 주변에 패딩을 제공합니다.
List 컴포넌트와 마찬가지로, FormSection을 사용하여 내용을 섹션별로 구분할 수 있습니다.

예시

enum NotifyMeAboutType {
    case directMessages, mentions, anything
}

enum ProfileImageSize {
    case large, medium, small
}

struct ContentView: View {
    @State private var notifyMeAbout: NotifyMeAboutType = .anything
    @State private var playNotificationSounds = false
    @State private var sendReadReceipts = false
    @State private var profileImageSize: ProfileImageSize = .small

    var body: some View {
        NavigationView {
            Form {
                Section(header: Text("Notifications"),
                        footer: Text("¿Qué quieres que te notifique?")) {
                    Picker("Notify Me About", selection: $notifyMeAbout) {
                        Text("Direct Messages").tag(NotifyMeAboutType.directMessages)
                        Text("Mentions").tag(NotifyMeAboutType.mentions)
                        Text("Anything").tag(NotifyMeAboutType.anything)
                    }
                    Toggle("Play notification sounds", isOn: $playNotificationSounds)
                    Toggle("Send read receipts", isOn: $sendReadReceipts)
                }
                Section(header: Text("User Profiles")) {
                    Picker("Profile Image Size", selection: $profileImageSize) {
                        Text("Large").tag(ProfileImageSize.large)
                        Text("Medium").tag(ProfileImageSize.medium)
                        Text("Small").tag(ProfileImageSize.small)
                    }
                    Button("Clear Image Cache") {}
                }
            }
        }
    }
}
Back to Blog

관련 글

더 보기 »

[SUI] 라벨드 콘텐츠

LabeledContent https://developer.apple.com/documentation/swiftui/labeledcontent 은 레이블을 컨트롤에 부착하는 컨테이너입니다. 기본 사용법 swift struct C...

[SUI] 검색 바

NavigationStack의 검색 바 NavigationStack은 `searchable` 수식어를 사용하여 검색 바를 포함할 수 있습니다. 그 서명은 다음과 같습니다: ```swift searchable(...) ```

[SUI] MultiDatePicker

MultiDatePicker 사용 MultiDatePicker는 SwiftUI에서 여러 날짜를 선택할 수 있게 합니다. Swift 초기화 메서드 MultiDatePicker.init(_:selection:in:) - titleKey: 레이블 키…