用于屏幕设计的像素到点

Pixel to point for screen designing

等一下,我知道已经有大量关于此的信息,但我发现它非常混乱并且不起作用(在我的情况下)。我有一位设计师向我发送了一份应用程序屏幕设计的 PDF,专为 iPhone 6 秒设计。该 PDF 中的间距以像素为单位。我已经看过 The Ultimate Guide To iPhone Resolutions, which almost everyone refers to. According to this article, I should convert the pixels in my PDF to point by dividing it by 2, since the iPhone 6S is rendered at 2x. However, when I do this and run my app in simulator it is nowhere close to what it looks in the PDF. Another thing that confused me is this article here,它说 iPhone 6 上的 1 点是 4 个像素。因此,如果我将 PDF 中的值除以 4,它看起来仍然不完美。我在这里做错了什么?如何将给定像素转换为要在 XCode.

中使用的点

PDF

您必须将您的 UIKit 组件分辨率除以二。例如,如果您有一些分辨率为 100x100 的图像。你的 UIImageView 应该是 50x50 点。这意味着在您的每个点中将有 4 个像素。

100 * 100 = 10_000 pixels
50 * 50 * 4 = 10_000 pixels

在 Assets 文件夹中应该有 3 个分辨率:

1x = 50 x 50
2x = 100 x 100
3x = 150 x 150

因为您的设计分辨率是iPhone 6s,使用2x文件夹。

希望对你有所帮助

截图中的PDF为350px高

标记为 180px 的间距约为 41px 高

41/350 = 屏幕高度的 0.1171

0.1171 * 1134 = 132,NOT 180 - 所以看起来 PDF 没有按比例缩放