SwiftUI 2: A Quick Overview
Label
A label is a Text
and an Image
together. Before you needed to create an HStack
with Text
and Image
, but now you can do it in one shot.
Before
Now
You can see the alignment is not perfect yet, but it will likely be fixed before it’s out of beta.
List Outline
The list outline is a beautiful new feature. It allows you to group elements of the same type to create a tree view.
The children have to be of the same type of elements of the list. For example, you couldn’t use the year to create a section.
Lazy Stack / Lazy Grid
The new lazy stack and lazy grid let you create views that will be loaded only if necessary. Just replace your stack to have this behavior.
Before
After
Link
Link
lets you open a URL quicker than before.
With the link, when you click on a cell, it will automatically open Safari and launch Google search. In this case, it will open a new Safari web page every time.
ProgressView
ProgressView
is a new component to handle progress, hence the name.
By default, the progress bar is a single line showing the progression.
The Circular Style shows the endless spin view.
IF LET / SWITCH
It’s not SwiftUI, but this will help a lot. Now in the code of SwiftUI, you can use if let and switch statement.
If Let works the same, it lets you work with optionals in a very nice and clean way. Same for the SWITCH statement.
The first day of WWDC was full of surprises and significant announcements. Let’s hope it will continue.
You can see the WWDC 2020 video: here.