We know that there are two screen sizes for Apple Watch: 38mm and 42mm. The WKInterfaceDevice
class provides a readable property named screenBounds
. I wrote an extension for WKInterfaceDevice
, trying to add a method to detect current device type.
import WatchKit
enum WatchResolution {
case Watch38mm, Watch42mm
}
extension WKInterfaceDevice {
class func currentResolution() -> WatchResolution {
let watch38mmRect = CGRectMake(0.0, 0.0, 136.0, 170.0)
let watch42mmRect = CGRectMake(0.0, 0.0, 156.0, 195.0)
let currentBounds = WKInterfaceDevice.currentDevice().screenBounds
if CGRectEqualToRect(currentBounds, watch38mmRect) {
return WatchResolution.Watch38mm
} else {
return WatchResolution.Watch42mm
}
}
}
Is that the correct method to detect Apple Watch size? Is there another method I am missing in the Apple docs?