SwiftUI changes in Xcode 11 Beta 3
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.
NavigationButton -> NavigationLink
NavigationView {
List {
Text("Hello World")
NavigationLink(destination: Text("Detail")) {
Text("Detail")
}
}
.navigationBarTitle(Text("Navigation Title"))
}
You can easily support sarunw.com by checking out this sponsor.
AI Grammar: Correct grammar, spell check, check punctuation, and parphrase.
PresentationButton -> PresentationLink
PresentationLink(destination: Text("Present"), label: { Text("Popup") })
.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)
}
You can easily support sarunw.com by checking out this sponsor.
AI Grammar: Correct grammar, spell check, check punctuation, and parphrase.
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 ShareUISplitViewController in SwiftUI
WWDC session shows us a way to create UISplitViewController with NavigationView in SwiftUI. It finally works in Xcode 11 Beta 3.