iOS 获取手机机型颜色 笔记

2019-05-30  本文已影响0人  豪冷
- (void)jh_deviceColor{
    UIDevice *device = [UIDevice currentDevice];
    SEL selector = NSSelectorFromString(@"deviceInfoForKey:");
    if (![device respondsToSelector:selector]) {
        selector = NSSelectorFromString(@"_deviceInfoForKey:");
        if ([device respondsToSelector:selector]) {
            IMP imp = [device methodForSelector:selector];
            NSString *(*func)(id ,SEL, NSString*) = (void *)imp;
            NSString *deviceColor = func(device,selector,@"DeviceColor");
            NSString *deviceEnclosureColor = func(device, selector, @"DeviceEnclosureColor");
            NSLog(@"deviceColor:%@,deviceEnclosureColor:%@", deviceColor,deviceEnclosureColor);
        }
    }
}
上一篇下一篇

猜你喜欢

热点阅读