I added a blur view in my app. If I run the app in the Simulator (iPhone 6, iOS 8.4) all works fine and the blur view is displayed. If I run the app on an device (iPad 3rd Gen., iOS 8.4) the blur view is displayed but doesn't displays a blurred background instead of this it displays a grey background. Don't know why. Do you know why and how to solve it?
Asked
Active
Viewed 453 times
0
-
Did you try the iPad simulator? Does it work as expected? – Acoop Oct 25 '15 at 22:17
-
Are you making sure to add your subviews of the blur view to the blur views contentView property? if you don't add subviews here I believe the behaviour is undefined. I would need to see screenshots to have a better idea what is happening. – Martin O'Shea Oct 25 '15 at 22:22
-
No it's also not working in the iPad Simulator. Don't know what to do. Example (grey part is the blur view): https://www.dropbox.com/s/e77uinulbqjmu81/Bildschirmfoto%202015-10-25%20um%2023.31.37.png?dl=0 – user5473123 Oct 25 '15 at 22:31
2 Answers
0
What code you are using?
func BlurEffect(){
let extraLightBlur = UIBlurEffect(style: .Dark)
let extraLightBlurView = UIVisualEffectView(effect: extraLightBlur)
self.addSubview(extraLightBlurView)
//let blurAreaAmount = CGRectMake(0, 0, frame.size.width, frame.size.height)
extraLightBlurView.frame = CGRectMake(0, 0, frame.size.width, frame.size.height)
let extraLightVibrancyView = vibrancyEffectView(forBlurEffectView: extraLightBlurView)
extraLightBlurView.contentView.addSubview(extraLightVibrancyView)
}
private func vibrancyEffectView(forBlurEffectView blurEffectView:UIVisualEffectView) -> UIVisualEffectView {
let vibrancy = UIVibrancyEffect(forBlurEffect: blurEffectView.effect as! UIBlurEffect)
let vibrancyView = UIVisualEffectView(effect: vibrancy)
vibrancyView.frame = blurEffectView.frame
//vibrancyView.autoresizingMask = .FlexibleWidth | .FlexibleHeight
return vibrancyView
}

Pravin S.
- 465
- 7
- 22
0
I ran into this problem too and wound up rolling my own blur effect using Core Image to create a UIView category. It works on a very old iPad mini and an iPod touch.
The header
//
// UIView+CIFilters.h
//
#import <UIKit/UIKit.h>
@interface UIView (CIFilters)
- (UIImageView *)blurredBackgroundViewWithRadius:(CGFloat)radius;
@end
The category
#import "UIView+CIFilters.h"
@implementation UIView (CIFilters)
- (UIImageView *)blurredBackgroundViewWithRadius:(CGFloat)radius {
UIView *snapshot = self;
// Get a CIImage from the view's contents
UIGraphicsBeginImageContextWithOptions(snapshot.bounds.size, snapshot.opaque, 0);
[snapshot drawViewHierarchyInRect:snapshot.bounds afterScreenUpdates:YES];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CIImage *snapshotImage = [CIImage imageWithCGImage:image.CGImage];
// Create a filter.
// This has to be applied first so that the edges of the CIGaussianBlur reach to the edge of the screen
// See the Core Image Filter Reference
CIFilter *clampFilter = [CIFilter filterWithName:@"CIAffineClamp"
withInputParameters:@{
kCIInputImageKey: snapshotImage
}];
CIImage *clampImage = [clampFilter valueForKey:kCIOutputImageKey];
CIFilter *blurFilter = [CIFilter filterWithName:@"CIGaussianBlur"
withInputParameters:@{
kCIInputImageKey: clampImage,
kCIInputRadiusKey:@(radius)
}
];
CIImage *blurredCIImage = [blurFilter valueForKey: kCIOutputImageKey];
CIContext *context = [CIContext contextWithOptions:nil];
CGImageRef cgImage = [context createCGImage:blurredCIImage fromRect:[snapshotImage extent]];
UIImage *blurredImage = [UIImage imageWithCGImage:cgImage];
UIImageView *blurredSnaphotview = [[UIImageView alloc] initWithImage:blurredImage];
return blurredSnaphotview;
}
@end
For example
UIImageView *blurredSnapshot = [self.view blurredBackgroundViewWithRadius:10.0];
will make a blurred snapshot of the entire view hierarchy of self.view where self is the current view controller. The larger the radius the blurrier the image. Substitute this view for a UIVisualEffectView.
Be sure to add CoreImage to your project frameworks.

Paul Linsay
- 449
- 4
- 6