在iOS8 +中,UIScreen上的-nativeScale和-scale有什么区别? [英] What is the difference between -nativeScale and -scale on UIScreen in iOS8+?

查看:1517
本文介绍了在iOS8 +中,UIScreen上的-nativeScale和-scale有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题中发布的示例日志中,结果完全相同。有谁知道这两者之间是否存在逻辑差异?

In sample logs posted in this question, the results are identical. Does anyone know if there is meant to be a logical difference between the two?

甚至 Apple的描述令人困惑。以下是 scale 的描述:

Even Apple's description is confusing. Here is the description of scale:


natural 与屏幕关联的比例因子
...
此值反映从默认逻辑坐标空间转换为此屏幕的设备坐标空间所需的比例因子...

The natural scale factor associated with the screen ... This value reflects the scale factor needed to convert from the default logical coordinate space into the device coordinate space of this screen...

这是他们的 nativeScale的描述

Here is their description of nativeScale:


物理屏幕的原生比例因子

自然原生有什么区别?

推荐答案

nativeBounds nativeScale 属性主要用于OpenGL,表示实际的像素大小和指向的点数p您可以使用ixels缩放系数精确绘制屏幕的分辨率,从而避免在虚拟1242×2208尺寸下绘制的额外渲染成本。例如,使用CAEAGLLayer,您可以这样做:

The nativeBounds and nativeScale properties are mostly meant for use with OpenGL and represent the actual pixel size and the points-to-pixels scaling factor that you’d use to draw to precisely the screen’s resolution, allowing you to avoid the additional rendering cost of drawing at the virtual 1242×2208 size. For instance, with a CAEAGLLayer, you’d do this:

theGLLayer.contentsScale = [UIScreen mainScreen].nativeScale;

...然后只需要以 nativeBounds的大小呈现其内容,即1080×1920。

…and then only have to render its content at the size of the nativeBounds, i.e. 1080×1920.

该问题的样本日志来自模拟器,模拟器始终不能保证与实际设备。

The sample logs in that question are from the simulator, which as always is not guaranteed to behave identically to an actual device.

这篇关于在iOS8 +中,UIScreen上的-nativeScale和-scale有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆