2022 SwiftUI & UI Frameworks
WWDC22 · 23 min · SwiftUI & UI Frameworks
What’s new in AppKit
Discover the latest advances in Mac app development using AppKit. We’ll take you through the latest updates to SF Symbols, show you how you can elevate your interface with enhanced controls, and help you learn to coordinate your windows with Stage Manager. We’ll also explore the latest sharing and collaboration features for macOS.
Watch at developer.apple.com ↗Code shown on screen · 1 snippet
Using the grouped form style in SwiftUI
enum AirDropVisbility: String, CaseIterable, Identifiable {
case nobody = "No One"
case contactsOnly = "Contacts Only"
case everyone = "Everyone"
var id: String { rawValue }
var label: String { rawValue }
var symbolName: String {
switch self {
case .nobody: return "person.crop.circle.badge.xmark"
case .contactsOnly: return "person.2.circle"
case .everyone: return "person.crop.circle.badge.checkmark"
}
}
}
struct ExampleFormView: View {
private var name: String = "Mac Studio"
private var screenSharingEnabled: Bool = true
private var fileSharingEnabled: Bool = false
private var airdropVisibility = AirDropVisbility.contactsOnly
var body: some View {
Form {
TextField("Computer Name", text: $name)
Toggle("Screen Sharing", isOn: $screenSharingEnabled)
Toggle("File Sharing", isOn: $fileSharingEnabled)
Picker("AirDrop", selection: $airdropVisibility) {
ForEach(AirDropVisbility.allCases) {
Label($0.label, systemImage: $0.symbolName)
.labelStyle(.titleAndIcon)
.tag($0)
}
}
}
.formStyle(.grouped)
}
} Related sessions
-
19 min -
28 min -
24 min -
18 min -
17 min