SwiftUI’s GroupBox, OutlineGroup, and DisclosureGroup in iOS 14

SwiftUI’s GroupBox, OutlineGroup, and DisclosureGroup in iOS 14

SwiftUI was inevitably going to see big changes this year, and I'm really excited to experiment with them all – text views, color pickers, progress

SwiftUI groups were introduced with iOS 13. They act as containers for wrapping different view types and also let you work around the 10 ChilidItem limit of VStack and HStack.

SwiftUI, in its second iteration at WWDC 2020, offers us a few new group controls. Namely, GroupBoxDisclosureGroup and OutlineGroup are now available in iOS 14 and above.

Let’s walk through each of these.


GroupBox

GroupBox is a stylized container view with an optional Label, and earlier it was only available in macOS. Now you can use it to logically group views and build things like a login screen, a custom alert dialog, and more.

Here’s the code that shows how to create a GroupBox in SwiftUI:

GroupBox(label: Label("Enter Details"), content: {

 VStack{
  TextField("Username", text: $text)
  Button(action: {}) {Text("Submit")}
 }
})

View modifiers work the same on GroupBox as they do on any other view. For instance, you can set shadows. The below screengrab shows a neumorphic design of the GroupBox in SwiftUI:

Image for post

Neumorphism is all about setting lights and shadows to give an extruding look, and that’s what’s done in the above code by using powerful view modifiers. The code is available in this gist.

swift ios swiftui programming mobile

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

SwiftUI Grids in iOS 14

SwiftUI was announced at WWDC 2019 and it paved a way for declarative programming for building interfaces. SwiftUI Grid comes in two different flavours, which includes LazyVGrid and LazyHGrid. As the name suggest, LazyVGrid is a Grid that flows in vertical direction and the LazyHGrid flows in horizontal direction

How to Build a Timer using Swift and SwiftUI

A great place to start building with SwiftUI

Understanding Grids in SwiftUI for iOS 14

SwiftUI was announced at WWDC 2019 and it paved a way for declarative programming for building interfaces. SwiftUI Grid comes in two different flavours, which includes LazyVGrid and LazyHGrid. As the name suggest, LazyVGrid is a Grid that flows in vertical direction and the LazyHGrid flows in horizontal direction.

Want More From ColorPicker in iOS 14? Create 1500+ SwiftUI Pickers of Your Own

Make custom colour pickers and reuse them in any project with Swift Package Manager

Top Swift iOS App Development Company in USA

AppClues Infotech is a top Mobile App Development Company in USA building high-quality Android, iOS, and Native apps for Startups, SMBs, & Enterprises. Contact us now!