I want to make universal game that support all iOS devices , beside making the project how to make my game support all screen sizes is there is a way to detect the screen size by code and change the graphic and the code according to the size , and what should the resolution of the graphics for each device ?
Asked
Active
Viewed 521 times
-2
-
1This question has already been asked many times. – sangony Aug 20 '15 at 19:25
-
i didn't found exactly what i want – RUON Aug 20 '15 at 19:28
-
Then for clarity you should add more detail to your question on what exactly you are looking for. – sangony Aug 20 '15 at 19:44
2 Answers
1
Use this code to determine the width and height of the screen. You can also find out what device is being used.
struct ScreenSize
{
static let SCREEN_WIDTH = UIScreen.mainScreen().bounds.size.width
static let SCREEN_HEIGHT = UIScreen.mainScreen().bounds.size.height
static let SCREEN_MAX_LENGTH = max(ScreenSize.SCREEN_WIDTH, ScreenSize.SCREEN_HEIGHT)
static let SCREEN_MIN_LENGTH = min(ScreenSize.SCREEN_WIDTH, ScreenSize.SCREEN_HEIGHT)
}
struct DeviceType
{
static let IS_IPHONE_4_OR_LESS = UIDevice.currentDevice().userInterfaceIdiom == .Phone && ScreenSize.SCREEN_MAX_LENGTH < 568.0
static let IS_IPHONE_5 = UIDevice.currentDevice().userInterfaceIdiom == .Phone && ScreenSize.SCREEN_MAX_LENGTH == 568.0
static let IS_IPHONE_6 = UIDevice.currentDevice().userInterfaceIdiom == .Phone && ScreenSize.SCREEN_MAX_LENGTH == 667.0
static let IS_IPHONE_6P = UIDevice.currentDevice().userInterfaceIdiom == .Phone && ScreenSize.SCREEN_MAX_LENGTH == 736.0
static let IS_IPAD = UIDevice.currentDevice().userInterfaceIdiom == .Pad && ScreenSize.SCREEN_MAX_LENGTH == 1024.0
}
You can println()
the values in the debugger.

Nick Pacini
- 195
- 2
- 12