如何获得设备比例因子? [英] How to get the devices scale factor?

查看:100
本文介绍了如何获得设备比例因子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用 UIGraphicsBeginImageContextWithOptions(),我注意到该方法中的最后一个字段是 scalefactor 。苹果文档说,如果我想将其设置为0.0,那么它将使用设备主屏幕的默认比例因子。有没有办法通过属性或方法获得默认比例因子?

I've been using UIGraphicsBeginImageContextWithOptions() and I noticed that the last field in that method is a scalefactor. And the apple docs says, if I want to set it to 0.0, then it will use the default scale factor of the device's main screen. Is there a way to get that default scale factor via property or method?

推荐答案

设备的比例因子是<$的属性C $ C> UIScreen 。你可以通过以下方式获得它:

The device's scale factor is a property of UIScreen. You can obtain it by:

[UIScreen mainScreen].scale;

这里的文档

这篇关于如何获得设备比例因子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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