0

How can I have a Form with one element in the Form taking up the full screen width? I tried putting the Form into a ScrollView but then there are other issues and it might not be a good idea to nest 2 scrolling views.

struct ContentView: View {

    var body: some View {
        Form {
            Text("Other content of Form")
            Section {
                Image(systemName: "pencil.circle.fill")
                    .resizable()
                    .aspectRatio(contentMode: .fill)
                    .listRowInsets(.none)
            }
        }
    }
}

This is how it looks now: Starting Layout

And this is what I want it to look: Desired Layout

Isaak
  • 1,107
  • 2
  • 11
  • 29
  • I ran your code, and it produces a full-width view. What's the desired behavior, here? What's not right? – West1 May 13 '21 at 08:10
  • set form padding to ```.padding(EdgeInsets(top: 0, leading: -25, bottom: 0, trailing: -25))``` – Raja Kishan May 13 '21 at 08:20
  • @West1 If you run it on narow iPhone (like SE1), the `Form` has no horizontal margin there - might this be the case? – Tomáš Kafka May 19 '22 at 10:32
  • @RajaKishan This doesn't work - first, a specific paddding value would break eg. on iPad, second, a Form still seems to crop the item to fit its boundaries no matter the padding. – Tomáš Kafka May 19 '22 at 10:48

1 Answers1

0

I decided to do a ScrollView and inset + style the child elements instead.

Isaak
  • 1,107
  • 2
  • 11
  • 29