presentationCornerRadius 설명회

SteadySlower·2023년 12월 26일
0

SwiftUI

목록 보기
57/64

presentationCornerRadius

기존에 SwiftUI의 Bottom Sheet는 Corner Radius를 수정할 수 없었다. 16.4 버전부터 지원하는 presentationCornerRadius를 사용하면 조정할 수 있다. 회사에서는 버전을 못 올리게 해서 못 쓰고 있다.

import SwiftUI

struct HomeView: View {
    
    @State var showBottomSheet: Bool = false
    @State var cornerRadius: CGFloat = 0.0
    
    var body: some View {
        VStack {
            Text("cornerRadius: \(cornerRadius)")
            Slider(value: $cornerRadius, in: 0...100)
            Button("show Bottom Sheet") {
                showBottomSheet = true
            }
        }
        .sheet(isPresented: $showBottomSheet, content: {
            ZStack {
                Color.black
                Text("Bottom Sheet Corner Radius of \(cornerRadius)")
            }
            .presentationCornerRadius(cornerRadius)
            .ignoresSafeArea()
        })
    }
    
}

업로드중..

profile
백과사전 보다 항해일지(혹은 표류일지)를 지향합니다.

0개의 댓글