判断机型

```

typedef NS_ENUM(char, iPhoneModel){  //0~3

iPhone4,//320*480

iPhone5,//320*568

iPhone6,//375*667

iPhone6Plus,//414*736

UnKnown

};



- (iPhoneModel)iPhonesModel {

CGRect rect = [[UIScreen mainScreen] bounds];

CGFloat width = rect.size.width;

CGFloat height = rect.size.height;

//get current interface Orientation

UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];

//unknown

if (UIInterfaceOrientationUnknown == orientation) {

return UnKnown;

}

if (UIInterfaceOrientationPortrait == orientation) {

if (width ==  320.0f) {

if (height == 480.0f) {

return iPhone4;

} else {

return iPhone5;

}

} else if (width == 375.0f) {

return iPhone6;

} else if (width == 414.0f) {

return iPhone6Plus;

}

}else if (UIInterfaceOrientationLandscapeLeft == orientation || UIInterfaceOrientationLandscapeRight == orientation) {

//landscape

if (height == 320.0) {

if (width == 480.0f) {

return iPhone4;

} else {

return iPhone5;

}

} else if (height == 375.0f) {

return iPhone6;

} else if (height == 414.0f) {

return iPhone6Plus;

}

}

return UnKnown;

}


```

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 闲来无事,认真整理了一下iPhone机型,查看博客的时候有点疑惑为什么有的判断机型有两种尺寸呢?为了解决这个问题,...
    小秀秀耶阅读 3,160评论 0 2
  • 1、禁止手机睡眠 [UIApplicationsharedApplication].idleTimerDisabl...
    小热狗阅读 995评论 0 2
  • 社会的急速发展,资讯的飞速更新,人人都在追求快速变化、快速成功,追求着一切新的事物。 我们每天手忙...
    清水05阅读 312评论 0 6
  • 今日我再次晕厥了,印象深刻的晕厥是在两年前,记得那一次是在明媚的三月,小高考结束的中午。趁我现在还记得清楚我决定要...
    长峰阅读 202评论 0 0
  • 刚刚听说“洪崖洞”这个名字时,我还以为是什么原始洞穴之类的东西。不过听说是宫崎骏一个电影的现实版,我又觉得它一定会...
    汎彼柏舟阅读 396评论 2 4

友情链接更多精彩内容