After building my SwiftUI for iOS 14 I've noticed that a lot of alignments were broken in forms.
Now each section seems to be in a rectangle with rounded corners and extra padding. It looks great on devices with large screens, but on smaller screens everything is cluttered and there is barely any space to display the content.
Looking around this seems to be a voluntary UI change from Apple, but I can't find a way to revert it since it doesn't work with my current layout.
Is this a known change in the default UI? Can I revert back to the way it was in iOS13 or do I have to rebuild everything on my own and not use a Form
view?
SwiftUI Form tutorial – how to create and use Form in SwiftUI. 1 Form with TextField. In order to create a basic form with text field, wrap your content view in NavigationView and then embed a Form within it: 2 Add Section and Toggle to the Form. 3 Add Picker to the Form. 4 Add Section with Stack and Text to the Form. 5 Add Button to the Form.
Editor’s note: We are updating our Swift books for SwiftUI. If you purchase it now, you’ll receive the update for free when the book is officially updated. Founder of AppCoda. Author of multiple iOS programming books including Beginning iOS Programming with Swift and Mastering SwiftUI. iOS App Developer and Blogger.
We set the label’s value to NAME and change its font type to headline. Like UIKit, the SwiftUI framework comes with a built-in text field component. To create a text field with a placeholder, you can write the code like this: To place the label above the text field, you can use a VStack to arrange both components.
But just like the time when we switched from Objective-C to Swift, you’ll enjoy writing the UI code in the declarative syntax once you manage it. You’ll feel more natural to describe the app layout you want.
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:
List {
//...
}
.listStyle(GroupedListStyle())
Before:
After:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With