iOS屏幕尺寸和分辨率了解

1、截至目前为止,主流的iOS设备屏幕有以下几种:

 

---------------  iPhone  ---------- --------  iPad ------------

 

2、iOS设备屏幕分辨率:(ppi是像素密度单位【像素/英寸】,401ppi表示每英寸上有401个像素)

  

  ppi(pixel per inch)计算,以6Plus为例:

  屏幕分辨率1920 x 1080,  屏幕尺寸5.5英寸(手机屏幕对角物理线的长度),

  1920 x 1920 + 1080 x 1080 = 4852800, 开根号为:2202.907...

  2202.907 / 5.5 = 400.528 ppi, 大约就是401ppi

 

3、iOS的三种分辨率

   1)、资源分辨率:资源图片的大小,单位是像素。

   2)、设计分辨率:逻辑上的屏幕大小,单位是点。我们在Interface Builder设计器中的单位和程序代码中的单位都是设计分辨率中的“点”。

   3)、是以像素为单位的屏幕大小,所有的应用都会渲染到这个屏幕上展示给用户。

     iPhone 6 Plus和 6S Plus是最为特殊的设备,资源分辨率与屏幕分辨率的比例是1.15 : 1, 而其他的设备比例是1 : 1。不同的人群关注的分辨率也是不同的,UI设计人员主要关注的是资源分辨率,开发人员主要关注的是设计分辨率,而一般用户主要关注的屏幕分辨率。

  

 4、获取设备屏幕信息

  获取当前移动设备对象:[UIDevice currentDevice]

  UIDevice类所有信息

NS_CLASS_AVAILABLE_IOS(2_0) @interface UIDevice : NSObject + (UIDevice *)currentDevice;@property(nonatomic,readonly,strong) NSString    *name;              // e.g. "My iPhone"
@property(nonatomic,readonly,strong) NSString    *model;             // e.g. @"iPhone", @"iPod touch"
@property(nonatomic,readonly,strong) NSString    *localizedModel;    // localized version of model
@property(nonatomic,readonly,strong) NSString    *systemName;        // e.g. @"iOS"
@property(nonatomic,readonly,strong) NSString    *systemVersion;     // e.g. @"4.0"
@property(nonatomic,readonly) UIDeviceOrientation orientation __TVOS_PROHIBITED;       // return current device orientation.  this will return UIDeviceOrientationUnknown unless device orientation notifications are being generated.

@property(nullable, nonatomic,readonly,strong) NSUUID      *identifierForVendor NS_AVAILABLE_IOS(6_0);      // a UUID that may be used to uniquely identify the device, same across apps from a single vendor.

@property(nonatomic,readonly,getter=isGeneratingDeviceOrientationNotifications) BOOL generatesDeviceOrientationNotifications __TVOS_PROHIBITED;
- (void)beginGeneratingDeviceOrientationNotifications __TVOS_PROHIBITED;      // nestable
- (void)endGeneratingDeviceOrientationNotifications __TVOS_PROHIBITED;@property(nonatomic,getter=isBatteryMonitoringEnabled) BOOL batteryMonitoringEnabled NS_AVAILABLE_IOS(3_0) __TVOS_PROHIBITED;  // default is NO
@property(nonatomic,readonly) UIDeviceBatteryState          batteryState NS_AVAILABLE_IOS(3_0) __TVOS_PROHIBITED;  // UIDeviceBatteryStateUnknown if monitoring disabled
@property(nonatomic,readonly) float                         batteryLevel NS_AVAILABLE_IOS(3_0) __TVOS_PROHIBITED;  // 0 .. 1.0. -1.0 if UIDeviceBatteryStateUnknown

@property(nonatomic,getter=isProximityMonitoringEnabled) BOOL proximityMonitoringEnabled NS_AVAILABLE_IOS(3_0); // default is NO
@property(nonatomic,readonly)                            BOOL proximityState NS_AVAILABLE_IOS(3_0);  // always returns NO if no proximity detector

@property(nonatomic,readonly,getter=isMultitaskingSupported) BOOL multitaskingSupported NS_AVAILABLE_IOS(4_0);@property(nonatomic,readonly) UIUserInterfaceIdiom userInterfaceIdiom NS_AVAILABLE_IOS(3_2);- (void)playInputClick NS_AVAILABLE_IOS(4_2);  // Plays a click only if an enabling input view is on-screen and user has enabled input clicks.@end

 

 ios移动设备类型枚举判断:

typedef NS_ENUM(NSInteger, UIUserInterfaceIdiom) {UIUserInterfaceIdiomUnspecified = -1,UIUserInterfaceIdiomPhone NS_ENUM_AVAILABLE_IOS(3_2), // iPhone and iPod touch style UIUIUserInterfaceIdiomPad NS_ENUM_AVAILABLE_IOS(3_2), // iPad style UIUIUserInterfaceIdiomTV NS_ENUM_AVAILABLE_IOS(9_0), // Apple TV style UI
};

[UIDevice currentDevice].userInterfaceIdiom ==  UIUserInterfaceIdiomPhone  // 表示iPhone设备

[UIDevice currentDevice].userInterfaceIdiom ==  UIUserInterfaceIdiomPad     // 表示iPad设备

[UIDevice currentDevice].userInterfaceIdiom ==  UIUserInterfaceIdiomTV  // 表示Apple TV设备

[UIDevice currentDevice].userInterfaceIdiom ==  UIUserInterfaceIdiomUnspecified  // 表示未知设备

 

//示例:详细判断iPhone设备类型

//详细判断iPhone设备信息, 区分横屏和竖屏if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone){//获取屏幕尺寸信息CGSize screenSize = [UIScreen mainScreen].bounds.size;//竖屏情况if (screenSize.height > screenSize.width){if (screenSize.height == 568){//iPhone 5/5S/5C (iPod / iPod touch) 等设备
            }else if (screenSize.height == 667){//iPone 6 / 6S 等设备
            }else if (screenSize.height == 736){//iPone 6 Plus / 6S Plus 等设备
            }else{//iPhone 4 / 4S 等设备
            }}//横屏情况if (screenSize.width > screenSize.height){if (screenSize.width == 568){//iPhone 5/5S/5C (iPod / iPod touch) 等设备
            }else if (screenSize.width == 667){//iPone 6 / 6S 等设备
            }else if (screenSize.width == 736){//iPone 6 Plus / 6S Plus 等设备
            }else{//iPhone 4 / 4S 等设备
            }}}

//说明:在iPad和iPhone屏幕中,一般会有状态栏、标签栏、导航栏(或工具栏)以及内容视图部分,它们的尺寸也是固定的。状态栏占20点,导航栏占44点,标签栏占49点。

 

 ppi(pixel  per  inch): 表示每英寸所包含的像素点数目,数值越高,屏幕能以更高密度显示图像

dpr(device pixel ratio): 设备像素比,设备像素 / 设备独立像素,表示设备独立像素到设备像素的转换关系

 

版权声明


作者:TDX

出处:博客园TDX的技术博客--http://www.cnblogs.com/tandaxia

您的支持是对博主最大的鼓励,感谢您的认真阅读。

本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

转载于:https://www.cnblogs.com/tandaxia/p/5060123.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/419173.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

“睡服”面试官系列第十七篇之Reflect(建议收藏学习)

目录 1. 概述 2. 静态方法 2.1Reflect.get(target, name, receiver) 2.2Reflect.set(target, name, value, receiver) 2.3Reflect.has(obj, name) 2.4Reflect.deleteProperty(obj, name) 2.5Reflect.construct(target, args) 2.6Reflect.getPrototypeOf(obj) 2.7Reflec…

java死锁检测

/*** author:cp* time:2021-2-24* Description: java死锁测试* 进程id查看命令:jsp 找到对应的进程id* 通过jstack 进程id 输出死锁信息** 如何定位死循环导致的其他线程阻塞等待:* linux下top命令查看cpu使用率较高的java进程&am…

div始终在底部

<style type"text/css">body{margin:0;padding:0; } html,body{height:100%;}div{width:100%;height:100px;background:#fc9;position:absolute;top:100%;margin-top:-100px}</style><div></div> 底部多高它的margin-top 就负多少。保证不留…

“睡服”面试官系列第十八篇之generator函数的语法(建议收藏学习)

目录 1简介 1.1基本概念 1.2yield 表达式 1.3与 Iterator 接口的关系 2. next 方法的参数 3. for...of 循环 4. Generator.prototype.throw() 5. Generator.prototype.return() 6. next()、throw()、return() 的共同点 7. yield* 表达式 8. 作为对象属性的 Generator…

微信撤回消息格式

<msg><fromusername>wxid_1zcdlm1cjhr522</fromusername><scene>0</scene><commenturl></commenturl><appmsg appid"" sdkver"0"><title>还好</title><des></des><action>…

MSSQL 2005数据库与SP4补丁安装

MSSQL 2005数据库与SP4补丁安装 Sql Server 2005 正确安装之前的win7配置&#xff1a; http://wenku.baidu.com/link?url6T3jzVnu2XY_sfqfe9ZqQ_6dUOdrZwHc83baWh6tgD2D4RBLnbFVoYn5hpq80v3G9ZmE1mQMzmSVWbm6VR26LlSGg3Pobl6B5VskugHjYF7 Sql Server 2005 的下载地址&#xff…

“睡服”面试官系列第十九篇之async函数(建议收藏学习)

目录 1. 含义 2. 基本用法 3. 语法 3.1返回 Promise 对象 3.2Promise 对象的状态变化 3.3await 命令 3.4错误处理 3.5使用注意点 4. async 函数的实现原理 5. 与其他异步处理方法的比较 6. 实例&#xff1a;按顺序完成异步操作 7. 异步遍历器 7.1异步遍历的接口 …

spring技术内幕——深入解析spring架构与设计原理

林纳斯托瓦兹&#xff08;Linus Torvalds&#xff09;说&#xff1a;“我从心底认为&#xff0c;优秀的程序员与平庸的程序员之间的区别&#xff0c;是在于认为自己的代码重要还是数据结构更加重要。平庸的程序员眼里只有代码&#xff0c;优秀的程序员则关注数据结构及之前的关…

python3 字符串方法

python3 字符串方法 1.capitalize() 将字符串的第一个字符改为大写 1 >>> si love cnblog 2 >>> s.capitalize() 3 I love cnblog 2.casefold() 将字符串所有字符改为小写 1 >>> (s.capitalize()).casefold() 2 i love cnblog 3.center(width) 将字…

重学算法第三期|数据结构与算法001

目录 强烈推荐一个数据结构可视化工具&#xff1a;https://www.cs.usfca.edu/~galles/visualization/Algorithms.html&#xff0c;点击B树即可模拟B树的动态插入过程&#xff0c;非常有利于理解 1、开篇词 2、为什么要学习数据结构与算法 3、如何抓住重点&#xff0c;系统高…

部署和调优 3.4 腾讯企业邮箱免费版 未完

浏览器输入腾讯的企业邮箱官网 exmail.qq.com 点右上角的 申请开通 最下面有个 免费版 填好基本信息 根据提示验证密保邮箱 转载于:https://www.cnblogs.com/wangshaojun/p/5079304.html

前端学习(1715):前端系列javascript之页面配置

test-page.vue <template><view>test-page</view> </template><script>export default {data() {return {}},methods: {}} </script><style></style>page.json {"pages": [ //pages数组中第一项表示应用启动页&a…

03|复杂度分析(上):如何分析、统计算法的执行效率和资源消耗?

目录 为什么需要复杂度分析&#xff1f; 大 O 复杂度表示法 时间复杂度分析 几种常见时间复杂度 空间复杂度分析 为什么需要复杂度分析&#xff1f; 事后统计法&#xff1a;代码跑一遍&#xff0c;通过统计、监控&#xff0c;就能得到算法执行的时间和占用的内存大小。这种…

前端学习(1716):前端系列javascript之页面配置下

page.vue {"pages": [ //pages数组中第一项表示应用启动页&#xff0c;参考&#xff1a;https://uniapp.dcloud.io/collocation/pages{"path" : "pages/test-page/test-page","style" : {"navigationBarTitleText":"t…

04 | 复杂度分析(下):浅析最好、最坏、平均、均摊时间复杂度

// n表示数组array的长度 int find(int[] array, int n, int x) {int i 0;int pos -1;for (; i < n; i) {if (array[i] x) {pos i;break;}}return pos; } 这段代码的时间复杂度还是 O(n) 吗&#xff1f;如果数组中第一个元素正好是要查找的变量 x&#xff0c;那就不需要…

Atitit.java swing打印功能 api  attilax总结

Atitit.java swing打印功能 api attilax总结 1. 打印方式有三种&#xff1a;2 1.1. 一是不经过任何修改&#xff0c;直接调用javascript中的window.print()打印。2 1.2. 二根据客户要求的报表格式&#xff0c;编写相应格式的html&#xff0c;装载数据打印&#xff0c;同样调用…

git clone 速度过慢

由于公司内网限制&#xff0c;通过git clone mybatis的源码时速度贼慢 原来的方式&#xff1a;git clone ​​​​​​​https://github.com/mybatis/mybatis-3.git 超级慢——失败 改进方式&#xff1a;git clone https://github.com.cnpmjs.org/mybatis/mybatis-3.git 贼快…

2016/1/4 学习笔记 数据类型转换 注释 语句

⑤ 数据类型转换 自动转换&#xff1a; 一般在算术运算过程中进行自 动转换为数字类型比较大的类型 由低级到高级转换 强制转换&#xff1a;又叫做显示转换。 1&#xff0c;从高精…

前端学习(1718):前端系列javascript之生命周期上

<script>export default {onLaunch: function() {console.log(App Launch)//登录//用户信息//存储},onShow: function() {console.log(App Show)//时间戳//计算用胡得使用时间},onHide: function() {console.log(App Hide)//应用进入后台所作得得事情},onError(e){consol…