gpt4 book ai didi

ios - 如何为 Retina 设置 Xcode 项目?

转载 作者:行者123 更新时间:2023-12-01 18:28:08 25 4
gpt4 key购买 nike

我正在尝试使用视网膜分辨率 (2048x1536) 构建我的应用程序但使用:

NSLog(@"resolution from xcode %f %f", [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);

我总是得到 1024x768解析度。任何想法如何设置视网膜分辨率?

最佳答案

你得到的是以点为单位的值(value),而不是像素。
来自 Apple's docs :

Points Versus Pixels

In iOS there is a distinction between the coordinates you specify in your drawing code and the pixels of the underlying device. When using native drawing technologies such as Quartz, UIKit, and Core Animation, you specify coordinate values using a logical coordinate space, which measures distances in points. This logical coordinate system is decoupled from the device coordinate space used by the system frameworks to manage the pixels on the screen. The system automatically maps points in the logical coordinate space to pixels in the device coordinate space, but this mapping is not always one-to-one. This behavior leads to an important fact that you should always remember:

One point does not necessarily correspond to one pixel on the screen.

The purpose of using points (and the logical coordinate system) is to provide a consistent size of output that is device independent. The actual size of a point is irrelevant. The goal of points is to provide a relatively consistent scale that you can use in your code to specify the size and position of views and rendered content. How points are actually mapped to pixels is a detail that is handled by the system frameworks. For example, on a device with a high-resolution screen, a line that is one point wide may actually result in a line that is two pixels wide on the screen. The result is that if you draw the same content on two similar devices, with only one of them having a high-resolution screen, the content appears to be about the same size on both devices.

关于ios - 如何为 Retina 设置 Xcode 项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11342081/

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