WatchKit: How to Check Device Screen Size in Code

The Apple Watch comes in two sizes – the 38mm and the 42mm. This means that you might need to do different logic based on the device screen size in code. In my case, I wanted to set a different image based on the device size.

There are currently two ways to check the Apple Watch device size in code:

Screen Bounds

Use the WKInterfaceDevice class to get the device bounds:

        let currentDevice = WKInterfaceDevice.currentDevice()
        let bounds = currentDevice.screenBounds
        // 38mm: (0.0, 0.0, 136.0, 170.0)
        // 42mm: (0.0, 0.0, 156.0, 195.0)
        
        if bounds.width > 136.0 {
            println("This is the big watch")
        } else {
            println("This is the small watch")
        }

Size Category

The WKInterfaceDevice class also has a size category option:

        let currentDevice = WKInterfaceDevice.currentDevice()
        let sizeCategory = currentDevice.preferredContentSizeCategory
        
        if sizeCategory == "UICTContentSizeCategoryL" {
            println("This is the big watch")
        }
        
        if sizeCategory == "UICTContentSizeCategoryS" {
            println("This is the small watch")
        }

UPDATE: I haven’t had a chance to actually test this on a device (and I only have one watch), but here’s a heads up about the Size Category from @schukin. So make sure to test on an actual device!

Conclusion

Personally, I really like the idea of using the Size Category, but the fact that it returns a hard-coded String vs an enum really has me nervous and worried. The screen bounds option seems a bit more solid at this point.

Enjoy the article? Join over 14,500+ Swift developers and enthusiasts who get my weekly updates.

  • Sulabh Surendran

    Will The size category fixes may be updated in coming versions like iOS 8.4?

    • I don’t work for Apple, so have no idea 🙂 I hope so!

      • Sulabh Surendran

        🙂 Hope they see this change and update.