How to accommodate for the iPhone 4 screen resolution?

后端 未结 8 494
隐瞒了意图╮
隐瞒了意图╮ 2020-11-29 03:59

According to Apple, the iPhone 4 has a new and better screen resolution:

3.5-inch (diagonal) widescreen Multi-Touch display
960-by-640-pixel res

8条回答
  •  半阙折子戏
    2020-11-29 04:45

    According to Supporting High-Resolution Screens In Views, from the Apple docs:

    On devices with high-resolution screens, the imageNamed:, imageWithContentsOfFile:, and initWithContentsOfFile: methods automatically looks for a version of the requested image with the @2x modifier in its name. It if finds one, it loads that image instead. If you do not provide a high-resolution version of a given image, the image object still loads a standard-resolution image (if one exists) and scales it during drawing.

    When it loads an image, a UIImage object automatically sets the size and scale properties to appropriate values based on the suffix of the image file. For standard resolution images, it sets the scale property to 1.0 and sets the size of the image to the image’s pixel dimensions. For images with the @2x suffix in the filename, it sets the scale property to 2.0 and halves the width and height values to compensate for the scale factor. These halved values correlate correctly to the point-based dimensions you need to use in the logical coordinate space to render the image.

提交回复
热议问题