본문 바로가기
Project/뿌대식: 부산대학교 학식 알리미

뿌대식: 개발 - 시트

by songmoro 2024. 1. 10.
728x90

기본 캠퍼스 지정을 위한 시트를 추가합니다.(모달/Modal 이라고도 부릅니다.)

 

 

<Sheet>

struct Sheet: View {
    @State var selectedCampus = Campus.부산
    
    var body: some View {
        VStack {
            RoundedRectangle(cornerRadius: 2.5)
                .foregroundColor(.darkGray100)
                .frame(width: UIScreen.getWidth(36), height: UIScreen.getHeight(5))
            
            HStack {
                Text("기본 캠퍼스")
                    .foregroundColor(.black100)
                
                Spacer()
                
                Picker(selection: $selectedCampus) {
                    ForEach(Campus.allCases, id: \\.self) {
                        Text($0.rawValue)
                    }
                    .foregroundColor(.blue100)
                } label: { }
                    .pickerStyle(.menu)
                
            }
            .font(.headline())
            
            Spacer()
        }
        .padding(.top)
        .frame(width: UIScreen.getWidth(350))
        .presentationDetents([.height(UIScreen.getHeight(238))])
    }
}

피커로 기본 캠퍼스를 지정하게 합니다.

기본 시트는 fullScreenCover(전체화면)와 sheet(전체크기)가 있는데 좀 더 작은 크기의 시트를 원하기 때문에 presentationDetents를 통해 시트의 크기를 지정해줍니다.

 

 

<화면 스크린샷>

728x90