检测iPhone / iPad / iPod touch的颜色?

编程入门 行业动态 更新时间:2024-10-25 04:25:56
本文介绍了检测iPhone / iPad / iPod touch的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否有任何方法或黑客可以检测iOS安装的iPhone,iPad或iPod touch的颜色(黑/白)?

Is there any way or hack to detect on what color (black / white) iPhone, iPad or iPod touch the iOS is installed?

我想在黑色或白色设备的情况下加载相应的UI皮肤。

I want to load corresponding UI skins in case of Black or White devices.

推荐答案

有一个私有API来检索 DeviceColor 和 DeviceEnclosureColor 。

There's a private API to retrieve both the DeviceColor and the DeviceEnclosureColor.

UIDevice *device = [UIDevice currentDevice]; SEL selector = NSSelectorFromString(@"deviceInfoForKey:"); if (![device respondsToSelector:selector]) { selector = NSSelectorFromString(@"_deviceInfoForKey:"); } if ([device respondsToSelector:selector]) { NSLog(@"DeviceColor: %@ DeviceEnclosureColor: %@", [device performSelector:selector withObject:@"DeviceColor"], [device performSelector:selector withObject:@"DeviceEnclosureColor"]); }

我发表了关于此的博客并提供了一个示例应用:

I've blogged about this and provide a sample app:

www.futuretap/blog/device-colors/

警告:如上所述,这是一个私有API。不要在App Store版本中使用它。

更多推荐

检测iPhone / iPad / iPod touch的颜色?

本文发布于:2023-08-01 15:44:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1269593.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:颜色   iPad   iPhone   touch   iPod

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!