import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib. var label = "1" //获取屏幕大小
let iOSDeviceScreenSize: CGSize = UIScreen.main.bounds.size NSLog("%@ x %@", iOSDeviceScreenSize.width, iOSDeviceScreenSize.height)
var s : NSString = NSString(format: "%@ x %@",iOSDeviceScreenSize.width,iOSDeviceScreenSize.height)
label = s as String //获取设备信息,判断是否为iphone
if (UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.phone) { //判断是否为竖屏
if (iOSDeviceScreenSize.height > iOSDeviceScreenSize.width){
if(iOSDeviceScreenSize.height == 568){
NSLog("iphone5/5s/5c/se")
} else if (iOSDeviceScreenSize.height == 667){
NSLog("iphone 6/6s/7/8")
} else if (iOSDeviceScreenSize.height == 736){
NSLog("iphone 6plus/6Splus/7plus/8plus ")
} else if (iOSDeviceScreenSize.height == 812){
NSLog("iphone X/XS ")
} else if (iOSDeviceScreenSize.height == 896){
NSLog("iphone XR/XSMax ")
} else {
NSLog("iphone4s....")
}
} if (iOSDeviceScreenSize.width > iOSDeviceScreenSize.height){
if(iOSDeviceScreenSize.width == 568){
NSLog("iphone5/5s/5c/se")
} else if (iOSDeviceScreenSize.width == 667){
NSLog("iphone 6/6s/7/8")
} else if (iOSDeviceScreenSize.width == 736){
NSLog("iphone 6plus/6Splus/7plus/8plus ")
} else if (iOSDeviceScreenSize.width == 812){
NSLog("iphone X/XS ")
} else if (iOSDeviceScreenSize.width == 896){
NSLog("iphone XR/XSMax ")
} else {
NSLog("iphone4s....")
}
} } } }

根据屏幕分辨率判断当前手机型号(swift4.1)的更多相关文章

  1. ios各个型号设备屏幕分辨率总结

    https://blog.csdn.net/amyloverice/article/details/79389357     iPhone: iPhone 1G 320x480 iPhone 3G 3 ...

  2. js判断屏幕分辨率的代码

    通过下面的代码判断分辨率 <script language="JavaScript"> <!-- Begin function redirectPage() { ...

  3. webapp开发——‘手机屏幕分辨率’与‘浏览器分辨率’不要混淆

    关于webApp响应式设计遇到的问题,分享给大家,最近在做一个手机webApp,因为我手机是”米3“,屏幕截图大小是1080宽,所以css样式用@media screen and(min-width: ...

  4. Android程序对不同手机屏幕分辨率自适应的方法

    相信各位Android开发爱好者都知道,由于OEM之间的竞争,各种Android操作系统的手机简直就是琳琅满目,屏幕分辨率的差异可想而知.目前比较主流的有WVGA=800x480,HVGA=480x3 ...

  5. Unity3D Android手机屏幕分辨率问题

    Android手机屏幕分辨率五花八门,导致开发时不好把握,还好各个引擎对这个屏幕分辨率问题都有较好的处理方式:unity3D 也为我们提供了一个不错的解决方案. 在Unity3D 进行 android ...

  6. 获取android手机的屏幕分辨率 android开发

    /** * 获取屏幕分辨率 */ private void getResolution() { // TODO Auto-generated method stub Display display = ...

  7. Unity3D NGUI自适应屏幕分辨率(2014/4/17更新)

    原地址:http://blog.csdn.net/asd237241291/article/details/8126619 原创文章如需转载请注明:转载自 脱莫柔Unity3D学习之旅 本文链接地址: ...

  8. 【Android 应用开发】分析各种Android设备屏幕分辨率与适配 - 使用大量真实安卓设备采集真实数据统计

    .主要是为了总结一下 对这些概念有个直观的认识; . 作者 : 万境绝尘  转载请注明出处 : http://blog.csdn.net/shulianghan/article/details/198 ...

  9. 分析各种Android设备屏幕分辨率与适配 - 使用大量真实安卓设备采集真实数据统计

    一. 数据采集 源码GitHub地址 : -- SSH : git@github.com:han1202012/DisplayTest.git; -- HTTP : https://github.co ...

随机推荐

  1. classpath和classpath*区别

    classpath和classpath*区别: classpath:只会到你的class路径中查找找文件. classpath*:不仅包含class路径,还包括jar文件中(class路径)进行查找. ...

  2. ASP.NET登录验证码解决方案

    目录 #验证码效果图 #代码 0.html代码 1.Handler中调用验证码生成类 2.验证码图片绘制生成类 3.高斯模糊算法类 #注意 #参考 在web项目中,为了防止登录被暴力破解,需要在登录的 ...

  3. C#中unit

    整理的百度百科的一些关于UNIT的资料 中文名UINT 外文名typedef unsigned short UIN 性    质 32位无符号整数 应    用 是unsigned int派生出来的 ...

  4. C#编程.异常处理(Exception Handling Statements)

    C#语言包含结构化异常处理(Structured Exception Handling,SEH). throw The throw statement is used to signal the oc ...

  5. Kotlin学习快速入门(1)——基本数据类型以及String常用方法使用

    本文适合有Java基础的人 Kotlin语法特点 相比java,省略括号,可以自动判断类型,省略new关键字,空指针捕获 主函数 kotlin文件(kt文件)中,只有要下列的方法,就可以运行,无需像之 ...

  6. spring aop(四)

    直接找到解析aop标签的方法: protected void parseBeanDefinitions(Element root, BeanDefinitionParserDelegate deleg ...

  7. python 读取文件1

    1.脚本 from sys import argv script,filename = argv txt = open(filename) print ("the filename is % ...

  8. IDEA自定义配置

    目录 1 常规设置 1 修改字体大小 2 创建文件时 增加注释信息 3 项目编码为UTF-8 4 properties 文件编码为UTF-8且Transparent native-to-ascii c ...

  9. 【iOS】获取视图的中心和宽高

    示例代码: NSLog(@"%f, %f", self.view.center.x, self.view.center.y); NSLog(@"%f, %f", ...

  10. ansible-service

    #service#查询服务状态 ansible server01 -m service -a "name=httpd state=started" #停止服务 ansible se ...