From the course: Apple watchOS 7 App Development Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Haptics - watchOS Tutorial
From the course: Apple watchOS 7 App Development Essential Training
Haptics
- While many devices have haptics, in watchOS, they have the most significant value, alerting a user to important information. Haptics work the same in both WatchKit, and SwiftUI for watchOS. Let's add a haptic to a button. I'm going to go to the detailed view here, and we've got a button right here for our selected item. So I'm going to do that, for our order. And the code itself is a single line, WKInterfaceDevice.current.play. Now inside play, there's one parameter, and that is the type of haptic feedback you want, which is a WKHapticType. And here's a list of all of them. We've got click, which is the most common of the haptics that you probably use, directionDown, Up, maneuvers, left and right turns, notification, retry, start, stop, and success. Now a lot of these are hard to actually perceive, I'm going to use success here, as an example one. So we've successfully ordered if we've hit this button. Usually…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.