11

I have 2 views in my code, a VStack and then a custom view.

I am adding an offset to the second view of -75, to move it on top of the first view.

Here is my current code:

Group {
       VStack {
           //First View
           VStack {
               Image("LogoCrest")

                NavigationLink(destination: LocationSearch()) {
                    Text("Find a location")
                    .foregroundColor(Color.white)
                    .bold()
                    .padding()
                }
                .frame(minWidth: 0, maxWidth: .infinity, alignment: Alignment.center)
                .background(Color(red: 81 / 255, green: 175 / 255, blue: 67 / 255))
                .cornerRadius(7)
                .padding()

           }
           .padding(.top, 75)
           .padding(.bottom, 75)
           .frame(minWidth: 0, maxWidth: .infinity, alignment: Alignment.center)
           .background(Color(red: 49 / 255, green: 49 / 255, blue: 49 / 255))

           //Second view
           CircuitList(Circuits: Circuits)
            .offset(y: -75)
           .padding()
       }
     }
    .background(Color(red: 232 / 255, green: 232 / 255, blue: 232 / 255))
    .edgesIgnoringSafeArea(.top)

How can I increase the height of the second view so it can always be at the bottom (see the black line in the image below for my desired extra height)?

My view

Matt Ward
  • 1,095
  • 1
  • 14
  • 28

1 Answers1

20

I have found the answer. Since I added y:-75 offset to my view, I had to add y:-75 padding too.

CircuitList(Circuits: Circuits)
    .offset(y: -75)
    .padding()
    .padding(.bottom, -75)
Matt Ward
  • 1,095
  • 1
  • 14
  • 28