美文网首页
获取iPhone外壳颜色

获取iPhone外壳颜色

作者: 大海啊都是水 | 来源:发表于2018-08-02 16:10 被阅读0次

    UIDevice *device = [UIDevice currentDevice];

        SEL selector = NSSelectorFromString(@"deviceInfoForKey:");

        if(![devicerespondsToSelector:selector]) {

            selector =NSSelectorFromString(@"_deviceInfoForKey:");

        }

        if([devicerespondsToSelector:selector]) {

            //消除警告"performSelector may cause a Leak because its selector is unknown"

            IMPimp = [devicemethodForSelector: selector] ;

            NSString* (*func)(id,SEL,NSString*) = (void*)imp;

            NSString*deviceColor = func(device, selector,@"DeviceColor");

            NSString*deviceEnclosureColor = func(device, selector,@"DeviceEnclosureColor");

            NSLog(@"deviceColor --> %@ \n @\"deviceEnclosureColor -->%@",deviceColor, deviceEnclosureColor);

        }

    相关文章

      网友评论

          本文标题:获取iPhone外壳颜色

          本文链接:https://www.haomeiwen.com/subject/dehzlttx.html