Search code examples
objective-cxcodeios9uivisualeffectviewuiblureffect

making uiview blur which contains a custom view which I want to remain unblured


I have 1custom UIView in my default view in viewcontroller.
My need is that if a button is clicked my default main view goes to blur and custom view remains unchanged.
And a button is clicked again the blured view returns to normal effect.
I used the UIBlurEffect and UIVisualEffectView for making blur.
But the problem is whole view got blured.


Solution

  • I've not tried the effects views yet, but they look like they participate as good citizens in the view hierarchy. If that's true, then this should work...

    // assume aView is the view you want blurred, and
    // aSubview is the view you want to remain unblurred 
    
    [aSubview removeFromSuperview];
    // apply the effect view to aView
    [aView addSubview:aSubview];