Skip to content

SwiftUI: Group

With VStack & HStack as a container, there is still a limitation of only 10 views that can be contained within. In order to bypass that limitation, you can use group to have more than 10 views.

An affordance for grouping view content.

Apple Documentation

In this tutorial, you’ll learn what it takes to build a Group in SwiftUI. You’ll learn:

  • How to build a Group from scratch.

Prerequisites

To follow along this tutorial, you’ll need some basic knowledge in:

  • A basic familiarity with Swift.
  • At least Xcode 11

Group

You can always think of this as a term of grouping some component together. To better demonstrate this, you will create a VStack that contains 10 views.

By adding 11th view, you will get an error “Type ‘CGFloat?’ does not conform to protocol ‘ExpressibleByIntegerLiteral“.

You can solve this by removing 10th View and replace it with Group.

Where to go From Here

If you feel like you are ready to take on more challenges, feel free to check out some other tutorials that we have created:

Published inSwiftUI

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright © DaddyCoding 2020.