iOS根据屏幕宽高判断当前设备型号
2015-10-22 15:37
483 查看
为了屏幕适配的需要,有时候我们需要获得iOS设备的屏幕信息,然后根据该信息判断是哪一种iOS设备。
CGSize screenSize = [UIScreen mainScreen].bounds.size; // 如果是iPhone if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) { // 竖屏情况 if (screenSize.height > screenSize.width) { if (screenSize.height == 568) { NSLog(@"当前为iPhone 5/5c/5s iPod Touch5 设备"); }else if (screenSize.height == 667) { NSLog(@"当前为iPhone6/6s设备"); }else if (screenSize.height == 736) { NSLog(@"当前为iPhone6 Plus/iPhone6s Plus 设备"); }else { NSLog(@"当前为iPhone4/4s 等其他设备"); } } // 横屏情况 if (screenSize.width > screenSize.height) { if (screenSize.width == 568) { NSLog(@"当前为iPhone 5/5c/5s iPod Touch5 设备"); }else if (screenSize.width == 667) { NSLog(@"当前为iPhone6/6s设备"); }else if (screenSize.width == 736) { NSLog(@"当前为iPhone6 Plus/iPhone6s Plus 设备"); }else { NSLog(@"当前为iPhone4/4s 等其他设备"); } } }
相关文章推荐
- iOS - 正则表达式判断邮箱、身份证..是否正确
- 【iOS】KVO方式监听数组的变化动态刷新tableView
- GCD实践——串行队列/并发队列与iOS多线程详解
- ios下拉刷新
- iOS项目开发之Socket编程 (转)
- ios 适配问题
- 使用IOS7原生API进行二维码条形码的扫描
- iOS项目问题汇总<二>
- android/ios js 启动apk
- iOS计算字符串高度
- iOS之多线程---三种多线程技术
- iOS 基础:证书介绍
- iOS 自定义tabbar的发现
- iOS之常用第三方开源框架介绍
- iOS应用逆向工程(二)
- iOS 单例的标准写法
- iOS 9之适配ATS
- ios 使用宏创建标准单利
- iOS 文件下载
- ios显示gif格式图片