UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Has there been a change in the layout of Forms?

Forums > SwiftUI

Following the videos and books from Paul, whenever a form was used, the layout was the same as that shown in the videos.

However, since I updated to XCode 12, iOS 14 and SwiftUI 2.0, whenever I layout a form, there is 'padding' of some sort to the left and right of the layout. This isn't the usual padding. It is as if the form can't be made to go edge to edge of the screen, and always has some sort of border around it.

Does anybody else have this issue, or is it just me?

Any help in getting rid of it will be most welcome.

Thanks in advance

Mark

2      

I noticed the same thing. In my case, I was using the Form specifically so that my PickerView could use the navigation view style picker. Now, with the (seemingly) enforced stylistic extra padding to the Form, my other items in my view that need to go edge to edge are getting squished.

While looking furter, I discovered that I could eliminate the need for a Form (in my case for the Picker behavior) by using a standard VStack and for my Picker I use .pickerStyle(MenuPickerStyle()). This allows (for my situation at least) a more in-flow solution as well as eliminating a lot of extraneous padding space taken up the the Picker in a Form otherwise.

May not be a solution for you, but ended up making a better design for me.

Picker(selection: $selectedIndex, label: Text(self.pickerLabelText()).font(.headline)) {
    ForEach(0 ..< self.items.count) {
        SelectedItemView(profile: self.items[$0])
    }
}
.padding()
.pickerStyle(MenuPickerStyle())
.onReceive([self.selectedIndex].publisher.first())
{ value in
    self.selectionDidChange(value)
}

4      

Thank you for that, I shall look into it. Am glad that I am not the only person it affected.

2      

It's the new default style but you could change your Form to a List and apply the listStyle modifier in order to get the old look back

List {
    //...
}
.listStyle(GroupedListStyle())

Reference : https://stackoverflow.com/questions/64169086/change-in-form-ui-in-ios-14-for-swiftui/64169477

2      

you can use what hdsenevi or .listStyle(InsetListStyle())

See ListStyle - Apple Developer Documenation

2      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.