100% SwiftUI Apps
We can now build an entire app completely in SwiftUI.
This is a fully functional app:
@main
struct HelloWorld: App {
var body: some Scene {
WindowGroup {
Text("Hello, world!").padding()
}
}
}We can do so thanks to the new
Appprotocol, which requires abodyof typesome Scene.WindowGrouplets us create scenes easily based on the platform, and more.DocumentGrouplets us open, edit, and save document-based scenes.
LaunchScreen
New
Launch ScreenInfo.plistkeyLets us declare standard UI components such as images, navigation bar, tab bar, background colors as the app launch screen.
Replaces the
LaunchScreen.storyboard.
Widgets
Built exclusively with SwiftUI
Widgets are just like Views, however instead of conforming to
View, they conform to theWidgetprotocol, and thebodyreturns asome WidgetConfigurationinstance.
Apple Watch
We can use SwiftUI to build custom complications
Lists
Stacks behave more like
Listby prepending them with with Lazy (e.g.LazyVStack)
Toolbar and Controls
New
.toolbarmodifier andToolBarItem, those are examples of semantic placements, we describe to SwiftUI the role that these toolbar items have, and SwiftUI will automatically place them properly.We can also specify the placement in the
ToolBarItemexplicitly in its initializernew View that combines a text and an image (in reality
Labelaccepts twoAnyViewinstances)Labels adapt neatly based on the context and dynamic type size, sometimes the text might not be shown (for example on navigation bars)
can display determinant and indeterminate progress
linear and circular style
customizable
used to display a value relative to a range (min/max)
Other important modifiers
.help.keyboardShortcut
Effects and Styling
We can add a new
AppAccentColorcolor assets in our bundle to have our app automatically adapt that accent color in all our UI.We can also customize some parts of our UI with a different color than the app accent color by using the relative tint modifier such as
listItemTint
System Integration
The new
Linkview lets open a webpage or deep link to another app, this is the equivalent of creating a button with aUIApplication.shared.openactiondrag and drop support
More integrations:
AVKit
MapKit
SceneKit
SpriteKit
QuickLook
HomeKit
ClockKit
StoreKit
WatchKit
