洞察探讨小游戏SDK接入的最佳实践以及对企业跨平台开发的优势
698
2022-11-10
[IOS]如何匹配iPhone 11等新机型
直接上代码:
if UIDevice().userInterfaceIdiom == .phone { switch UIScreen.main.nativeBounds.height { case 1136: print("iPhone 5 or 5S or 5C") case 1334: print("iPhone 6/6S/7/8") case 1920, 2208: print("iPhone 6+/6S+/7+/8+") case 2436: print("iPhone X/XS/11 Pro") case 2688: print("iPhone XS Max/11 Pro Max") case 1792: print("iPhone XR/ 11 ") default: print("Unknown") } }
Object-C:
if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { switch ((int)[[UIScreen mainScreen] nativeBounds].size.height) { case 1136: printf("iPhone 5 or 5S or 5C"); break; case 1334: printf("iPhone 6/6S/7/8"); break; case 1920, 2208: printf("iPhone 6+/6S+/7+/8+"); break; case 2436: print("iPhone X/XS/11 Pro"); break; case 2688: print("iPhone XS Max/11 Pro Max"); break; case 1792: print("iPhone XR/ 11 "); break; default: printf("Unknown"); break; }}
参考:https://stackoverflow.com/questions/46192280/detect-if-the-device-is-iphone-x
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~