Skip to content

Instantly share code, notes, and snippets.

@lluisgerard
Created January 14, 2014 17:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lluisgerard/8422427 to your computer and use it in GitHub Desktop.
Save lluisgerard/8422427 to your computer and use it in GitHub Desktop.
iOS :: Know if a device is capable of doing iOS7 blur effect (using UIToolBar hack) Using: https://github.com/lmirosevic/GBDeviceInfo
+ (BOOL)allowsBlurEffect {
// I assume that any device that is not checked here is newer and therefore is "blur" capable
static BOOL isAllowed = YES;
static BOOL isChecked = NO;
if (!isChecked) {
isChecked = YES;
GBDeviceDetails *deviceDetails = [GBDeviceInfo deviceDetails];
// iOS 7 at least
isAllowed = (deviceDetails.majoriOSVersion >= 7);
if (isAllowed) {
// If we have minimum iOS, now check the device
switch (deviceDetails.family) {
case GBDeviceFamilyiPhone:
// iPhone -- 4S at least
isAllowed = deviceDetails.majorModelNumber >= 4;
break;
case GBDeviceFamilyiPod:
// iPod --- 5 Gen at least
isAllowed = deviceDetails.majorModelNumber >= 5;
break;
case GBDeviceFamilyiPad:
// iPad ---- At least 4
isAllowed = deviceDetails.majorModelNumber >= 4;
// Maybe is an iPad mini and it is allowed
if (!isAllowed)
isAllowed = deviceDetails.model == (GBDeviceModeliPadMini | GBDeviceModeliPadMiniRetina);
default:
break;
}
}
NSLog(@"Device %@ blur effect", isAllowed ? @"ALLOWS" : @"DON'T ALLOWS");
}
return isAllowed;
}
@lluisgerard
Copy link
Author

Use at your own risk, wrote this in just 2 minutes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment