Detect if device properly displays UIVisualEffectView?
Asked Answered
G

2

13

My app utilizes UIVisualEffectView to blur the background just like Control Center. But I discovered the iPad 2 (and Retina iPad) which can run iOS 8 isn't powerful enough to display that effect so it reverts to a gray color. I would like to be able to detect if the device the app is running on is powerful enough to display the blur effect, and if not I won't apply it, instead I'll change the background color to something that looks much better than that gray color. But I don't want to just check if the device is an iPad 2 or iPad 3rd gen (does it affect 4th as well?). Is there a better way to detect if the UIBlurEffect will appear as expected?

Gibbeon answered 16/10, 2014 at 18:16 Comment(1)
Any luck with this? Same problem here.Bucky
E
9

Check this WWDC session: http://asciiwwdc.com/2014/sessions/419

So, and to reiterate on what devices we don't blur and that we only do the tinting on the iPad 2 and iPad 3rd generation, we just apply the tint and we skip the blur steps.

[...]

On iPad 4th generation, iPad Air, iPad Mini, iPad Mini with retina display, iPhones and the iPod touch we do both the blur and the tinting.

I guess you have to resort to checking for the machine name:

#import <sys/utsname.h>
...

struct utsname systemInfo;
uname(&systemInfo);

NSString *deviceName = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
...
Emma answered 16/11, 2014 at 8:19 Comment(1)
This example is incomplete. I would also like to see example of how to set the tint color to be non-gray.Edveh
C
2

Apple internally uses [UIDevice _graphicsQuality] for these kind of checks. In the following post I propose a method that does the same using only public API: https://mcmap.net/q/907500/-check-if-device-supports-blur

Chalkstone answered 10/1, 2015 at 17:59 Comment(1)
FWIW, there are hardware devices that don't support UIVisualEffectView that are not listed in that category: iPhone4,1, iPhone5,1Greggrega

© 2022 - 2024 — McMap. All rights reserved.