Skip to content

Instantly share code, notes, and snippets.

@aheze
Created May 29, 2020 03:28
Show Gist options
  • Save aheze/54b32bed6ebaacf161787b6f529e3b49 to your computer and use it in GitHub Desktop.
Save aheze/54b32bed6ebaacf161787b6f529e3b49 to your computer and use it in GitHub Desktop.
enum DeviceType {
//MARK: - iPhones
/**
iPhone 5, iPhone 5S, iPhone 5C, iPhone SE 1st gen
*/
case iPhoneSE1
/**
iPhone 6, iPhone 6S, iPhone 7, iPhone 8, iPhone SE 2nd gen
*/
case iPhoneSE2
/**
iPhone 6 Plus, iPhone 6S Plus, iPhone 7 Plus, iPhone 8 Plus
*/
case iPhone8Plus
/**
iPhone X, iPhone XS, iPhone 11 Pro
*/
case iPhoneX
/**
iPhone XR, iPhone 11
*/
case iPhone11
/**
iPhone XS Max, iPhone 11 Pro Max
*/
case iPhone11ProMax
//MARK: - iPads
/**
iPad Mini 2nd, 3rd, 4th and 5th Generation
*/
case iPadMini
/**
iPad 3rd, iPad 4th, iPad Air 1st, iPad Air 2nd, iPad Pro 9.7-inch, iPad 5th, iPad 6th Generation
*/
case iPad9_7
/**
iPad 7th Generation
*/
case iPad10_2
/**
iPad Pro 10.5, iPad Air 3rd Generation
*/
case iPad10_5
/**
iPad Pro 11-inch 1st and 2nd Generation
*/
case iPadPro11
/**
iPad Pro 12.9-inch 1st, 2nd, 3rd and 4th Generation
*/
case iPadPro12
func getSize() -> CGSize {
switch self {
case .iPhoneSE1:
return CGSize(width: 320, height: 568)
case .iPhoneSE2:
return CGSize(width: 375, height: 667)
case .iPhone8Plus:
return CGSize(width: 414, height: 736)
case .iPhoneX:
return CGSize(width: 375, height: 812)
case .iPhone11:
return CGSize(width: 414, height: 896)
case .iPhone11ProMax:
return CGSize(width: 414, height: 896)
case .iPadMini:
return CGSize(width: 768, height: 1024)
case .iPad9_7:
return CGSize(width: 768, height: 1024)
case .iPad10_2:
return CGSize(width: 810, height: 1080)
case .iPad10_5:
return CGSize(width: 834, height: 1112)
case .iPadPro11:
return CGSize(width: 834, height: 1194)
case .iPadPro12:
return CGSize(width: 1024, height: 1366)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment