Created
June 11, 2019 07:19
-
-
Save KanshuYokoo/7c7ccc3bacea4b34269c59f56822005a to your computer and use it in GitHub Desktop.
ios device types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import UIKit | |
struct DeviceInfos { | |
static let IS_IPAD = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.pad) | |
static let IS_IPHONE = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.phone) | |
static let IS_RETINA = (UIScreen.main.scale >= 2.0) | |
static let SCREEN_WIDTH = (UIScreen.main.bounds.size.width) | |
static let SCREEN_HEIGHT = (UIScreen.main.bounds.size.height) | |
static let SCREEN_MAX_LENGTH = SCREEN_WIDTH >= SCREEN_HEIGHT ? SCREEN_WIDTH : SCREEN_HEIGHT | |
static let SCREEN_MIN_LENGTH = SCREEN_WIDTH <= SCREEN_HEIGHT ? SCREEN_WIDTH : SCREEN_HEIGHT | |
static let IS_IPHONE_4_OR_LESS = (IS_IPHONE && SCREEN_MAX_LENGTH < 568.0) | |
static let IS_IPHONE_5 = (IS_IPHONE && SCREEN_MAX_LENGTH == 568.0) | |
static let IS_IPHONE_6 = (IS_IPHONE && SCREEN_MAX_LENGTH == 667.0) | |
static let IS_IPHONE_6P = (IS_IPHONE && SCREEN_MAX_LENGTH == 736.0) | |
static let IS_IPHONE_6_AND_UPPER = (IS_IPHONE && SCREEN_MAX_LENGTH >= 667.0) | |
static let IS_IPHONE_X_AND_UPPER = (IS_IPHONE && SCREEN_MAX_LENGTH >= 812.0) | |
static let IPHONE_X_STATUS_BAR_HEIGHT_ADDITION = 22.0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment