개발/SWIFT 아이폰 / / 2023. 7. 19. 18:27

SwiftUi Status Bar, Safe Area, Bottom Area 색상 변경

반응형

GeometryReader를 이용해 Status Bar, Safe Area, Bottom Area 영역 지정 후 색상 변경

struct ContentView: View {
    var body: some View {
        GeometryReader { geometry in
            VStack(spacing: 0) {
                
                // Status Bar
                Color.gray
                    .frame(height: geometry.safeAreaInsets.top)
                
                // Safe Area
                VStack {
                    
                }
                .frame(width: geometry.size.width, height: geometry.size.height)
                .background(Color.orange)
                
                // Bottom Area
                Color.yellow
                    .frame(height: geometry.safeAreaInsets.bottom)
            }
            .edgesIgnoringSafeArea(.all)
        }
    }
}

반응형
  • 네이버 블로그 공유
  • 네이버 밴드 공유
  • 페이스북 공유
  • 카카오스토리 공유