In the application development of Apple devices, we often need to deal with screen resolution issues, including normal screens and retain screens.
When you work with screen resolution, you can divide it into point resolution and pixel (PIXER) resolution. When we look at the device parameters, we see the pixel resolution generally, because it is larger and looks taller. Next, let's take an example of an iphone device to see how the point resolution and pixel resolution are handled separately in development.
First, create a single view app under iOS in Xcode, and then create the relevant code in the Viewdidload method in the VIEWCONTROLLER.M. application file.
The following code shows the point resolution of the current device.
Cgsize size = [[UIScreen mainscreen] bounds].size; NSLog (@ "Points:width (%f), height (%f)", Size.width, size.height);
If the device being tested uses the Retain screen, the above code shows that the data is much lower than the identified resolution parameter, and the following code shows the full pixel resolution.
Cgsize size = [[UIScreen mainscreen] bounds].size;float scale = [UIScreen mainscreen].scale; NSLog (@ "Pixers:width (%f), height (%f)", size.width * scale, size.height * scale);
In the second piece of code, we used the screen's scale property, whose value is the point-to-pixel relationship. If the scale value is 1, the device does not use the retain screen, and if it is greater than 1, the device uses the Retain screen, or if the scale property value is 3, a point on the screen contains 9 (3*3) pixels (pixer).
In general, it is possible to use only point coordinates in the interface development of an iOS or MacOS system, which simplifies many coordinate processing tasks. Note that the Uikit interface's origin (0,0) is in the upper-left corner, while the interface origin in Spritekit is in the lower-left corner.
Resolution issues in Apple devices