Parth Adroja
Parth Adroja

Reputation: 13514

How to find which apple watch 38 or 42mm?

What is the correct way to find out which apple watch is it programmatically whether it's 38mm or 42mm? How can I make a struct object for the same to access it like below:

if watch.size == 38 { 
} else { 
}

Upvotes: 3

Views: 444

Answers (1)

Sagar Thummar
Sagar Thummar

Reputation: 2124

You can check Apple Watch size in below following way:-

public struct watch {

     public static var screenWidth: CGFloat {
          return WKInterfaceDevice.current().screenBounds.width
     }

     public static var is38: Bool {
          return screenWidth == 136
     }

     public static var is42: Bool {
          return screenWidth == 156
     }
}

Upvotes: 3

Related Questions