iOS Code Snippet Make Blur Any View

Hi,

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

B4X:
Sub ApplyBlur( View as View)
dim nome as NativeObject=Me
nome.RunMethod("MakeBlur:",Array(view))
End sub

#If OBJC

-(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
 

susu

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.
 

susu

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

ilan

Expert
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:
 
Top