gpt4 book ai didi

iphone - 如何适配iPhone 4屏幕分辨率?

转载 作者:行者123 更新时间:2023-12-03 18:16:43 24 4
gpt4 key购买 nike

根据Apple ,iPhone 4 拥有新的、更好的屏幕分辨率:

3.5-inch (diagonal) widescreen Multi-Touch display
960-by-640-pixel resolution at 326 ppi

这个小细节对我们的应用程序有很大影响。网络上的大多数演示应用程序都有一个共同点:它们认为屏幕具有 320 x 480 像素的固定尺寸来定位 View 。因此,大多数(如果不是全部)开发人员所做的是:他们以这样的方式设计所有内容,可触摸区域的大小(例如)为 50 x 50 像素。只要敲一下就够了。事物已相对于左上角定位,以到达屏幕上的特定位置 - 比如说中心或底部的某个位置。

当我们开发高分辨率应用时,它们可能无法在旧设备上运行。如果他们这样做,他们将因任何图像大小为 4 倍而遭受很大损失,必须在内存中缩小它们。

最佳答案

根据Supporting High-Resolution Screens In Views ,来自苹果文档:

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.

关于iphone - 如何适配iPhone 4屏幕分辨率?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2992360/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com