-
A UIScreen object contains the bounding rectangle of the device ' s entire screen. When setting up your application's user interface, you should use the properties of this object to get the recommended FRA Me rectangles for your application ' s window. The UIScreen object contains the bounding rectangle of the entire screen. When constructing the user interface interface for your app, you should use the object's properties to get the recommended rectangle size to construct your program window. The properties and actions listed below have been used by me. + mainscreen returns the Screen object representing the device ' s SCR een. bounds property contains The bounding rectangle of the screen, measured in points. (read-only) applicationframe property the frame rectangle for the app window. (read-only) scale property The natural scale factor associated with the screen. (read-only) [plain] cgrect bound = [[UIScreen mainscreen] bounds]; //returns a rect with a status bar cgrect frame = [[UIScreen mainscreen] applicationframe]; //returns a rect that does not have a status bar float scale = [[UiscreenmainScreen] scale]; Get the natural resolution of the device for the scale attribute need to be further explained: The previous iphone device screen resolution was 320*480, and then Apple adopted a display technology called Retina in iphone 4, The IPhone 4 features a 960x640 pixel resolution display screen. With the screen size unchanged or 3.5 inches, the resolution boosts the iphone 4 display resolution to four times times the iphone 3GS, with 326 pixels per inch of area. The scale attribute has a value of two: scale = 1; Represents the current device is the 320*480 resolution (that is, the device before iphone4) scale = 2; Is the resolution for 640*960 resolution Judging screen type: [Plain] //judging screen type, normal or retina float scale = [[UIScreen Mainscreen] scale]; if (scale = = 1) { Bisretina = NO; NSLog (@ "normal screen"); }else if (scale = = 2) { Bisretina = YES; NSLog (@ "Retina screen"); }else{ NSLog (@ "unknow screen mode!"); Understanding of DPI and PPI: DPI is the number of dots per inch that can be easily understood as the density of points. The PPI is the number of pixels per inch and can be simply understood as pixel density. Is there a difference between dots and pixels? Many times, a point = one pixel. But, not really, like the iphone's Retina screen, it has a point that contains four pixels, greatly improving the display sharpness. The bounds and frame obtained using UIScreen are point rulers.Rather than the pixel size. For example, on the iPhone4 of the Retina screen, the applicationframe size I get is 320x460, which obviously represents the number of points. If you want to display a picture, if the original size is 100x200, then on such a screen, it actually shows that the size will be only half the size of the original, but its number of pixels has not changed. More to consider, if you want to scale the graph, then the zoom rate is calculated according to the actual display size, or according to the actual number of pixels? This piece is very important, has gone a lot of detours, the answer is the former.
UIScreen's Scale property