Close Menu
  • Home
  • AI
  • Big Data
  • Cloud Computing
  • iOS Development
  • IoT
  • IT/ Cybersecurity
  • Tech
    • Nanotechnology
    • Green Technology
    • Apple
    • Software Development
    • Software Engineering

Subscribe to Updates

Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

    What's Hot

    Agencies

    April 26, 2026

    When Production Logs Become Your Best QA Asset

    April 26, 2026

    PFAS removal from industrial wastewater: How can activated carbon help?

    April 26, 2026
    Facebook X (Twitter) Instagram
    Facebook X (Twitter) Instagram
    Big Tee Tech Hub
    • Home
    • AI
    • Big Data
    • Cloud Computing
    • iOS Development
    • IoT
    • IT/ Cybersecurity
    • Tech
      • Nanotechnology
      • Green Technology
      • Apple
      • Software Development
      • Software Engineering
    Big Tee Tech Hub
    Home»iOS Development»ios – How to ignoreSafeArea when presenting content in SwiftUI Sheet?
    iOS Development

    ios – How to ignoreSafeArea when presenting content in SwiftUI Sheet?

    big tee tech hubBy big tee tech hubDecember 20, 2025022 Mins Read
    Share Facebook Twitter Pinterest Copy Link LinkedIn Tumblr Email Telegram WhatsApp
    Follow Us
    Google News Flipboard
    ios – How to ignoreSafeArea when presenting content in SwiftUI Sheet?
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link


    I present a SwiftUI View using a UIHostingController with modalPresentationStyle = .overCurrentContext. Inside this root SwiftUI view, I present a .sheet with a custom modifier to make the sheet background transparent.

    Minimal Reproducible Code:
    import SwiftUI

    class SheetViewModel: ObservableObject {
        @Published var isPresented: Bool = true
    }
    
    struct RootSheetWrapper: View {
        @StateObject var viewModel: SheetViewModel
        
        var body: some View {
            // Transparent host view acting as the anchor for the sheet
            Color.clear
                .customTransparentSheet(isPresented: $viewModel.isPresented, height: 400) {
                    SheetContent()
                }
        }
    }
    
    // Minimal version of my custom sheet extension
    extension View {
        func customTransparentSheet(
            isPresented: Binding,
            height: CGFloat,
            @ViewBuilder content: @escaping () -> Content
        ) -> some View {
            ZStack {
                self
                SomeOverlay()
            }
            self.sheet(isPresented: isPresented) {
                content()
                    .presentationDragIndicator(.hidden)
                    .applyTransparentBackground() 
                    .presentationDetents([.height(height)])
            }
        }
    }
    
    private extension View {
        @ViewBuilder
        func applyTransparentBackground() -> some View {
            if #available(iOS 16.4, *) {
                self.presentationBackground(.clear)
            } else {
                self.background(Color.clear.ignoresSafeArea())
            }
        }
    }
    

    Sheet Content:

        struct SheetContent: View {
            var body: some View {
                VStack(spacing: 0) {
                    // This image should sit behind the home indicator
                    Image(systemName: "star.fill")
                        .resizable()
                        .aspectRatio(contentMode: .fill)
                        .frame(maxWidth: .infinity)
                }
                // This makes the background transparent, but the bottom safe area 
                // still clips the Red background/Image above.
                // .ignoresSafeArea(.all) // <--- THIS DOES NOT WORK
            }
        }
    

    I present it like this:

    func presentSheet() {
            let viewModel = SheetViewModel()
            let hostView = RootSheetWrapper(viewModel: viewModel)
            
            let hostingController = UIHostingController(rootView: hostView)
            hostingController.modalPresentationStyle = .overCurrentContext
            hostingController.view.backgroundColor = .clear
            hostingController.modalTransitionStyle = .crossDissolve
            
            self.present(hostingController, animated: true)
        }
    

    What I have tried:
    Applying .ignoresSafeArea() on the VStack inside SheetContent.
    Applying .background(Color.clear, ignoresSafeAreaEdges: .bottom)

    I do see the sheet taking up safe area if I provide the height of the content and sheet to be less than the height of the image, is subtracting height of bottom safe area only way? Please help.



    Source link

    Content ignoreSafeArea iOS presenting sheet SwiftUI
    Follow on Google News Follow on Flipboard
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Copy Link
    tonirufai
    big tee tech hub
    • Website

    Related Posts

    ios – Apply shadow only outside of a SwifUI transparent button?

    April 26, 2026

    ios – How to add pictures after keynote update with iPadOS 26.3.1?

    April 25, 2026

    ios – AVCaptureDevice.exposurePointOfInterest readback does not match set value on iPad Pro M4 / M3(UltraWide)and Gen2,3,4(TrueDepth) using resizeAspectFill

    April 25, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Editors Picks

    Agencies

    April 26, 2026

    When Production Logs Become Your Best QA Asset

    April 26, 2026

    PFAS removal from industrial wastewater: How can activated carbon help?

    April 26, 2026

    A Practical Guide to Optimizing Hosting Deployment |

    April 26, 2026
    Timer Code
    15 Second Timer for Articles
    20
    About Us
    About Us

    Welcome To big tee tech hub. Big tee tech hub is a Professional seo tools Platform. Here we will provide you only interesting content, which you will like very much. We’re dedicated to providing you the best of seo tools, with a focus on dependability and tools. We’re working to turn our passion for seo tools into a booming online website. We hope you enjoy our seo tools as much as we enjoy offering them to you.

    Don't Miss!

    Agencies

    April 26, 2026

    When Production Logs Become Your Best QA Asset

    April 26, 2026

    Subscribe to Updates

    Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

      • About Us
      • Contact Us
      • Disclaimer
      • Privacy Policy
      • Terms and Conditions
      © 2026 bigteetechhub.All Right Reserved

      Type above and press Enter to search. Press Esc to cancel.