iOS Code Snippet Make Blur Any View


This small code will allow to apply a blur effect to any view.

Sub ApplyBlur( View as View)
dim nome as NativeObject=Me
End sub


-(void)MakeBlur: (UIView*)view
if (!UIAccessibilityIsReduceTransparencyEnabled()) {
    view.backgroundColor = [UIColor clearColor];

    UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
    UIVisualEffectView *blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
    blurEffectView.frame = view.frame;
    blurEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

    [view addSubview:blurEffectView];
else {
    view.backgroundColor = [UIColor blackColor];

#End if


Well-Known Member
Licensed User
I tried your code on iPhone 4 with iOS 7.1.2
My app crash without any error even in Debug mode. How can I fix it? Thanks.


Well-Known Member
Licensed User
Oh, that's why. Thanks.


Licensed User
I tested on iPhone 4 with iOS 7.

I think i was misunderstood, i know that you used ios 7 and i understand that it runs only from ios8+ so i asked if it is possible to add an if statement to avoid a crash

So if app run on ios 7 do nothing only if app run on ios 8+ then do the code... to avoid crashes so i assumed he updated the code after you report a crash, but i dont see a "last edited..." in the first post :confused: