[SwiftUI] Date Picker

RudinP·5일 전
0

Study

목록 보기
318/325

@State private var selectedDate = Date.now
    
    var body: some View {
        VStack {
            Spacer()
            
            Text(selectedDate, style: .date)
                .font(.largeTitle)
            
            Text("선택한 날짜")
                .font(.callout)
                .foregroundColor(.secondary)
            
            Spacer()
            
            DatePicker("날짜 선택", selection: $selectedDate, displayedComponents: .date)
                .padding()
           //displayedComponents에 [.date, .hourAndMinute] 과 같이 배열로 전달하면 전부 선택 가능
        }
    }

style

  • iOS에서 automatic = compact
  • graphical은 전체 달력 표시
  • wheel
profile
iOS 개발자가 되기 위한 스터디룸...

0개의 댓글