HomeiOS Developmentios - .edgesIgnoringSafeArea(.prime) results width and causes web page content material to...

ios – .edgesIgnoringSafeArea(.prime) results width and causes web page content material to shrink


I am making a full-page vertical scroll like TikTok.

I am in a position to take action utilizing the next code:

struct ViewA: View {
    let colours: [Color] = [ .red, .green, .blue, .gray ]

    var physique: some View {
        GeometryReader { proxy in
            TabView {
                ForEach(colours, id: .self) { shade in
                    ZStack {
                        shade
                        VStack {
                            Textual content("Whats up World")
                        }
                    }
                }
                .rotationEffect(.levels(-90))
                .body(
                    width: proxy.measurement.width,
                    top: proxy.measurement.top
                )
            }
            .body(
                width: proxy.measurement.top,
                top: proxy.measurement.width
            )
            .rotationEffect(.levels(90), anchor: .topLeading)
            .offset(x: proxy.measurement.width)
            .tabViewStyle(
                PageTabViewStyle(indexDisplayMode: .by no means)
            )
        }
    }
}

preview

Nonetheless, after I take away the highest protected space(make the content material fill the complete display together with protected space) utilizing .edgesIgnoringSafeArea(.prime), my content material shrinks in width a bit.

var physique: some View {
    GeometryReader { proxy in
        TabView {
            ForEach(colours, id: .self) { shade in
                ZStack {
                    shade
                    VStack {
                        Textual content("Whats up World")
                    }
                }
            }
            .rotationEffect(.levels(-90))
            .body(
                width: proxy.measurement.width,
                top: proxy.measurement.top
            )
        }
        .body(
            width: proxy.measurement.top,
            top: proxy.measurement.width
        )
        .rotationEffect(.levels(90), anchor: .topLeading)
        .offset(x: proxy.measurement.width)
        .tabViewStyle(
            PageTabViewStyle(indexDisplayMode: .by no means)
        )
    }
    .edgesIgnoringSafeArea(.prime) <----- This line causes the issue
}

preview

I am very new to native ios growth please assist. TIA~!

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments