Latest 0.1
Homepage https://github.com/djmadcat/UIDevice-BlurEnabled
License BSD
Platforms ios 5.0, requires ARC
Dependencies UIView-JTViewToImage, OBShapedButton
Frameworks UIKit, CoreGraphics
Authors

UIDevice-BlurEnabled

UIDevice category to check whether blur is enabled.

Overview

This is a hack method to check whether blur is enabled on current device. It is based on testing of rendering blur effect at runtime.

How it works

  1. We create UIView with custom backgroundColor
  2. Add UIToolbar with translucent = YES to UIView
  3. Add UIView to UIWindow beyond the screen (this allows you to perform UIView rendering)
  4. Check rendered colors with tricky algorithm
  5. Remove UIView from UIWindow

You must check be_blurEffectEnabled at every applicationDidBecomeActive: call or by subscribing to UIApplicationDidBecomeActiveNotification in your controller or custom view to fix views’ rendering settings.

Dependencies

  • 'UIView-JTViewToImage', '~> 0.1' to take screenshot of UIView as UIImage
  • 'OBShapedButton', '~> 1.0.2' to access the pixel color

Example usage

#import "UIDevice+BlurEnabled.h"

@implementation BEViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIDevice *currentDevice = [UIDevice currentDevice];
    NSLog(@"Blur supported by device and OS: %@", [currentDevice be_blurEffectSupported] ? @"YES" : @"NO");
    NSLog(@"Blur active ('increase contrast' disabled): %@", [currentDevice be_blurEffectActive] ? @"YES" : @"NO");
    NSLog(@"Blur enabled (supported && active): %@", [currentDevice be_blurEffectEnabled] ? @"YES" : @"NO");
}

@end

Read more

Contact

Alexey Aleshkov

License

UIDevice-BlurEnabled is available under the BSD 2-Clause license. See the LICENSE file for more info.

Latest podspec

{
    "name": "UIDevice+BlurEnabled",
    "version": "0.1",
    "authors": {
        "Alexey Aleshkov": "[email protected]"
    },
    "license": {
        "type": "BSD",
        "file": "LICENSE"
    },
    "homepage": "https://github.com/djmadcat/UIDevice-BlurEnabled",
    "summary": "UIDevice category to check whether blur is enabled.",
    "source": {
        "git": "https://github.com/djmadcat/UIDevice-BlurEnabled.git",
        "tag": "0.1"
    },
    "requires_arc": true,
    "platforms": {
        "ios": "5.0"
    },
    "source_files": "UIDevice+BlurEnabled/*.{h,m}",
    "dependencies": {
        "UIView-JTViewToImage": [
            "~> 0.1"
        ],
        "OBShapedButton": [
            "~> 1.0.2"
        ]
    },
    "frameworks": [
        "UIKit",
        "CoreGraphics"
    ]
}

Pin It on Pinterest

Share This