Digital Crown

Episode #253 | 11 minutes | published on January 27, 2017 | Uses watchOS-3
Subscribers Only
In this episode, Conrad Stoll takes us through the new APIs we have for accessing raw information from the digital crown on the Apple Watch. In previous versions of watchOS, we had to resort to using builtin controls (or silly hacks), but now we have the raw data so we have much more flexibility.

Episode Links

Setting up the Crown Sequencer

self.crownSequencer.delegate = self
self.crownSequencer.focus()

Using the Crown Sequencer's Rotational Delta

func crownDidRotate(_ crownSequencer: WKCrownSequencer?, rotationalDelta: Double) {
    if rotationalDelta < 0 {
        // Decreasing
    } else if rotationalDelta > 0 {
        // Increasing
    }
}

Using the Crown Sequencer's Velocity

if let rotationsPerSecond = crownSequencer?.rotationsPerSecond {
    if rotationsPerSecond > 1.0 {
        // Increase delta
    }
}

Noticing When the Crown Stopped Moving

func crownDidBecomeIdle(_ crownSequencer: WKCrownSequencer?) {

}
blog comments powered by Disqus