⌚
【watchOS】watchKit x SwiftUIで使用できるUIまとめ

以前まではwatchOS AppのUI設計はStoryboardを使用していました。しかし、watchOS 7以降はStoryboardを使用したUIの設計は非推奨[1]となっており、新規でwatchOS Appを開発する場合はSwiftUIを使用してUIを設計する必要があります。
本記事ではSwiftUIを使用してwatchOS Appを開発する時に使うことができるUIをまとめました。
サンプルコードは以下のGitHubに置いていますのでご自由にご参照ください。
View
Text

Label

LabeledContent

Button

Image

Slider

Stepper

Picker

ProgressView

Gauge

Toggle

TextField

SecureField

Custom Font

Chart

Map

SCNScene

Media
動画の再生

音声の再生

NowPlayingView

Transition
NavigationLink

Modal

Tab

Alert

Other
Digital Crownの回転数を取得

Haptic Feedback

タップ座標の取得

モーションの取得

参考資料
Creating a watchOS App Build a productivity app for Apple Watch
-
Xcode 14 Release Notes "WatchKit storyboards are deprecated in watchOS 7.0 and later. Please migrate to SwiftUI and the SwiftUI Lifecycle. (94058186)"
https://developer.apple.com/documentation/xcode-release-notes/xcode-14-release-notes ↩︎
Discussion