Everything announced at WWDC 2020 that SwiftUI brings for iOS 14 — Focused on User Interface

ML Musings
3 min readJun 23, 2020

--

SwiftUI for iOS 14 brings a lot of new cool features. Through this article, I will list down most or all of the new cool features that got announced at WWDC 2020.

“SwiftUI offers new features, improved performance, and the power to do, even more, all while maintaining a stable API that makes it easy to bring your existing SwiftUI code forward into Xcode 12. A brand new life cycle management API for apps built with SwiftUI lets you write your entire app in SwiftUI and share even more code across all Apple platforms. And a new widget platform built on SwiftUI lets you build widgets that work great on iPad, iPhone, and Mac. Your SwiftUI views can now be shared with other developers, and appear as first-class controls in the Xcode library. And your existing SwiftUI code continues to work, while providing faster performance, better diagnostics, and access to new controls” — Apple Developer Website

1. Views

TextEditor:

A text editor view allows you to display and edit multiline, scrollable text in your app’s UI.

struct TextEditingView: View {
@State var text = "This is some editable text"
var body: some View {
TextEditor(text: $fullText)
}
}

Sign in With Apple:

You can create a Sign in with Apple button for your app

SignInWithAppleButton(
.signIn,
onRequest: { request in
request.requestedScopes = [.fullName, .email]
},
onCompletion: { result in
switch result {
case .success (let authResults):
print("Authorization successful.")
case .failure (let error):
print("Authorization failed: " + error.localizedDescription)
}
}
)

Menu

A control for presenting a menu of actions.

Menu("Actions") {
Button("Duplicate", action: duplicate)
Button("Rename", action: rename)
Button("Delete…", action: delete)
Menu("Copy") {
Button("Copy", action: copy)
Button("Copy Formatted", action: copyFormatted)
Button("Copy Library Path", action: copyPath)
}
}

ColorPicker

A control used to select a color from the system color picker UI.

struct FormattingControls: View {
@State private var bgColor =
Color(.sRGB, red: 0.98, green: 0.9, blue: 0.2)
var body: some View {
VStack {
ColorPicker("Alignment Guides", selection: $bgColor)
}
}
}

ProgressView

A view that shows the progress towards completion of a task.

@State private var progress = 0.5 VStack {
ProgressView(value: progress)
Button("More", action: { progress += 0.05 })
}

Label

A standard label for user interface items, consisting of an icon with a title.

Label("Lightning", systemImage: "bolt.fill")

Link

A control for navigating to a URL.

Link("View Our Terms of Service",      destination: URL(string: "https://www.example.com/TOS.html")!)

2. Layouts

LazyHStack

A view that arranges its children in a line that grows horizontally, creating items only as needed.

ScrollView {
LazyHStack(alignment: .top, spacing: 10) {
ForEach(1...100, id: \.self) {
Text("Column \($0)")
}
}
}

LazyVStack

A view that arranges its children in a line that grows vertically, creating items only as needed.

ScrollView {
LazyVStack(alignment: .top, spacing: 10) {
ForEach(1...100, id: \.self) {
Text("Row \($0)")
}
}
}

LazyHGrid

A container view that arranges its child views in a grid that grows horizontally, creating items only as needed. More: https://developer.apple.com/documentation/swiftui/lazyhgrid

LazyVGrid

A container view that arranges its child views in a grid that grows vertically, creating items only as needed. More: https://developer.apple.com/documentation/swiftui/lazyvgrid

These are only some of the few cherry-picked updates from everything that got launched today at WWDC 2020

Some other cool things you could do with SwiftUI for iOS14

  1. Control which view is showing when you launch your app
  2. Map View
  3. onChange()
  4. Use ScrollViewReader, ScrollViewProxy to move to a location programmatically
  5. Open Web Links in Safari
  6. Play videos in VideoPlayer
  7. Grouped Lists, and many more

Thanks for reading! Let’s keep building cool stuff, and never stop learning:)

--

--

ML Musings
ML Musings

Written by ML Musings

✨ I enjoy pushing the boundaries of JS, Python, SwiftUI and AI. You can support my work through coffee - www.buymeacoffee.com/MLMusings

No responses yet