1

Here is the screen shot: enter image description here

The code to the view is as follows:

struct ViewDetails: View {

    @EnvironmentObject var displayDetails: DisplayDetails

    var body: some View { 

        ScrollView {

            GeometryReader { geometry in

                ZStack {

                    if geometry.frame(in: .global).minY <= 0 {

                        Image("header")
                            .resizable()
                            .aspectRatio(contentMode: .fill)
                            .frame(width: geometry.size.width, height: geometry.size.height)
                            .offset(y: geometry.frame(in: .global).minY/9)
                            .clipped()

                    } else {

                        Image("header")
                            .resizable()
                            .aspectRatio(contentMode: .fill)
                            .frame(width: geometry.size.width, height: geometry.size.height + geometry.frame(in: .global).minY)
                            .clipped()
                            .offset(y: -geometry.frame(in: .global).minY)

                     }

                }   

            }.frame(height: 400)

            VStack(alignment: .leading) {

                HStack {

                    Image("author")
                        .resizable()
                        .aspectRatio(contentMode: .fill)
                        .frame(width: 60, height: 60)
                        .clipped()
                        .cornerRadius(10)

                    VStack(alignment: .leading) {

                        Text("Article by")
                            .font(.custom("AvenirNext-Regular", size: 15))
                            .foregroundColor(.gray)

                        Text("John Doe")
                            .font(.custom("AvenirNext-Demibold", size: 15))

                    }

                }.padding(.top, 20)

                Text("Lorem ipsum dolor sit amet")
                    .font(.custom("AvenirNext-Bold", size: 30))
                    .lineLimit(nil)
                    .padding(.top, 10)

                Text("3 min read • 22. November 2019")
                    .font(.custom("AvenirNext-Regular", size: 15))
                    .foregroundColor(.gray)
                    .padding(.top, 10)

                Text(articleContent)
                    .font(.custom("AvenirNext-Regular", size: 20))
                    .lineLimit(nil)
                    .padding(.top, 30)

            }
            .frame(width: 350)

        }
        .edgesIgnoringSafeArea(.all)

            .onAppear(perform: {

                self.displayDetails.showFullScreen.toggle()

            })

    }

}

So I'm not sure if I can remove whatever is displaying as gray/white at the bottom or if I can change the color for it, either way works for me but I am unable to achieve it!? Can anyone help.

Learn2Code
  • 1,974
  • 5
  • 24
  • 46
  • Putting a .background(Color.black) above .edgesIgnoringSafeArea(.all) on your ScrollView should do the job! – KevinP Mar 01 '20 at 17:16

1 Answers1

2

I changed your code a little and ran it on the simulator. The only change is just adding .background(Color.yellow) before .edgesIgnoringSafeArea(.all). Here is the full code snippet with result:

struct ViewDetails: View {

    var body: some View {

        ScrollView {

            GeometryReader { geometry in

                ZStack {

                    if geometry.frame(in: .global).minY <= 0 {

                        Image("hp")
                            .resizable()
                            .aspectRatio(contentMode: .fill)
                            .frame(width: geometry.size.width, height: geometry.size.height)
                            .offset(y: geometry.frame(in: .global).minY/9)
                            .clipped()

                    } else {

                        Image("header")
                            .resizable()
                            .aspectRatio(contentMode: .fill)
                            .frame(width: geometry.size.width, height: geometry.size.height + geometry.frame(in: .global).minY)
                            .clipped()
                            .offset(y: -geometry.frame(in: .global).minY)

                     }

                }

            }.frame(height: 400)


            VStack(alignment: .leading) {

                HStack {

                    Image("author")
                        .resizable()
                        .aspectRatio(contentMode: .fill)
                        .frame(width: 60, height: 60)
                        .clipped()
                        .cornerRadius(10)

                    VStack(alignment: .leading) {

                        Text("Article by")
//                            .font(.custom("AvenirNext-Regular", size: 15))
                            .foregroundColor(.gray)

                        Text("John Doe")
                            .font(.custom("AvenirNext-Demibold", size: 15))

                    }

                }.padding(.top, 20)

                Text("Lorem ipsum dolor sit amet")
//                    .font(.custom("AvenirNext-Bold", size: 30))
                    .lineLimit(nil)
                    .padding(.top, 10)

                Text("3 min read • 22. November 2019")
                    .font(.custom("AvenirNext-Regular", size: 15))
                    .foregroundColor(.gray)
                    .padding(.top, 10)

                Text("articleContent")
                    .font(.custom("AvenirNext-Regular", size: 20))
                    .lineLimit(nil)
                    .padding(.top, 30)

            }
            .frame(width: 350)


        }
        .background(Color.yellow)
            .onAppear(perform: {

            //                self.displayDetails.showFullScreen.toggle()

                        })
        .edgesIgnoringSafeArea(.all)   

    }

result:

enter image description here

P.S: There are lots of unnecessary details in your code snippets, so it's hard to analyze it =(

Hrabovskyi Oleksandr
  • 3,070
  • 2
  • 17
  • 36