import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
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
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....")
}
}
}
}
}
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步