SwiftUI changes in Xcode 11 Beta 3

⋅ 1 min read ⋅ SwiftUI iOS beta

Table of Contents

Today release of Xcode 11 Beta 3 brings some change to SwiftUI components. I will highlight some obvious one, you can check the rest here.

You can easily support sarunw.com by checking out this sponsor.

Sponsor sarunw.com and reach thousands of iOS developers.
NavigationView {
List {
Text("Hello World")
NavigationLink(destination: Text("Detail")) {
Text("Detail")
}
}
.navigationBarTitle(Text("Navigation Title"))
}

Reference

PresentationLink(destination: Text("Present"), label: { Text("Popup") })

Reference

.tabItemLabel -> .tabItem

We can finally use SF Symbol here and we can init .tabItem with Image and Text directly without VStack.

TabbedView {
Text("First")
.font(.title)
.tabItem { Text("First") }
.tag(0)
Text("Second")
.font(.title)
.tabItem {
Image(systemName: "circle")
Text("Second")
}
.tag(1)
}

Reference

You can easily support sarunw.com by checking out this sponsor.

Sponsor sarunw.com and reach thousands of iOS developers.

New initializer for most views with label

Most SwiftUI views got a initializer accepting @ViewBuilder as a label which quite verbose for most case where we just need simple Text.

In this beta 3 those views get a new initializer which accept LocalizedStringKey.

Instead of.

Button(action: {
print("Button tapped")
}) {
Text("Button")
}

We can shorten it with.

Button("Button") {
print("Button tapped")
}

You can checkout my compiled cheat sheet here.


Read more article about SwiftUI, iOS, beta, or see all available topic

Enjoy the read?

If you enjoy this article, you can subscribe to the weekly newsletter.
Every Friday, you'll get a quick recap of all articles and tips posted on this site. No strings attached. Unsubscribe anytime.

Feel free to follow me on Twitter and ask your questions related to this post. Thanks for reading and see you next time.

If you enjoy my writing, please check out my Patreon https://www.patreon.com/sarunw and become my supporter. Sharing the article is also greatly appreciated.

Become a patron Buy me a coffee Tweet Share
Previous
How to use UIKit in SwiftUI

Using UIView and UIViewController in SwiftUI

Next
UISplitViewController in SwiftUI

WWDC session shows us a way to create UISplitViewController with NavigationView in SwiftUI. It finally works in Xcode 11 Beta 3.

← Home