-
Update your app for watchOS 10
Join us as we update an Apple Watch app to take advantage of the latest features in watchOS 10. In this code-along, we'll show you how to use the latest SwiftUI APIs to maximize glanceability and reorient app navigation around the Digital Crown.
Chapitres
- 1:33 - Build against the watchOS 10 SDK
- 2:33 - NavigationSplitView
- 5:21 - TabView and vertical pagination
- 8:11 - Toolbar with new placement options
- 9:07 - Background color
- 11:10 - Materials
Ressources
Vidéos connexes
WWDC23
-
Rechercher dans cette vidéo…
-
-
4:02 - NavigationSplitView
NavigationSplitView { List(backyardsData.backyards, selection: $selectedBackyard) { backyard in BackyardCell(backyard: backyard) } .listStyle(.carousel) } detail: { if let selectedBackyard { BackyardView(backyard: selectedBackyard) } else { BackyardUnavailableView() } } -
6:18 - Vertical TabView
TabView { TodayView() .navigationTitle("Today") HabitatGaugeView(level: $waterLevel, habitatType: .water, tintColor: .blue) .navigationTitle("Water") HabitatGaugeView(level: $foodLevel, habitatType: .food, tintColor: .green) .navigationTitle("Food") List { VisitorView() .navigationTitle("Visitors") } } .tabViewStyle(.verticalPage) -
8:37 - Add refill button to Toolbar
.toolbar { ToolbarItemGroup(placement: .bottomBar) { Spacer() Button { level = Int(min(100, Double(level) + 5)) } label: { Label("Add", systemImage: "plus") } } } -
9:48 - HabitatGaugeView background color function and variables
func backgroundColor(_ level: Int, for type: HabitatType) -> Color { let color: Color = type == .food ? .green : .blue return level < 40 ? .red : color } var waterColor: Color { backgroundColor(waterLevel, for: .water) } var foodColor: Color { backgroundColor(foodLevel, for: .food) } -
10:10 - .containerBackground within TabView
TabView { TodayView() .navigationTitle("Today") .containerBackground(Color.accentColor.gradient, for: .tabView) HabitatGaugeView(level: $waterLevel, habitatType: .water, tintColor: waterColor) .navigationTitle("Water") .containerBackground(waterColor.gradient, for: .tabView) HabitatGaugeView(level: $foodLevel, habitatType: .food, tintColor: foodColor) .navigationTitle("Food") .containerBackground(foodColor.gradient, for: .tabView) List { VisitorView() .navigationTitle("Visitors") .containerBackground(Color.accentColor.gradient, for: .tabView) } } .tabViewStyle(.verticalPage) .environmentObject(backyard) .navigationTitle(backyard.displayName) -
11:38 - Add material to the backyard name
.foregroundStyle(.secondary) .background(Material.ultraThin, in: RoundedRectangle(cornerRadius: 7)) -
12:15 - Visitor score overlay with materials
.overlay(alignment: .topTrailing) { Text("\(backyard.visitorScore)") .frame(width: 25, height: 25) .foregroundStyle(.secondary) .background(.ultraThinMaterial, in: .circle) .padding(.top, 5) } -
12:20 - Light materials
.environment(\.colorScheme, .light)
-