I would like to change the value of a recursive array.

One array provides the `path` to the variable to change:

`$scopePath` represents the path to change.

For example `if $scopePath==Array("owners","products","categories")`

and $tag="price";

I would like to change `$value["owners"]["products"]["categories"]["tag"]` to `true`

```
    $u=$value;
    foreach ($scopePath as $i => $s) {
        if (!isset($u[$s]))
            $u[$s]=Array();
        $u=$u[$s];
    }
    $u[$tag]=true;

```

I know the problem is because of the line $u=$u[$s] because this changes the reference to $u, but I don't know how to fix it.
['https://Stackoverflow.com/questions/17041685', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1993501/']
Core Image
----------

Since that image in the screenshot is static, you could use `CIGaussianBlur` from Core Image (requires iOS 6). Here is sample: <https://github.com/evanwdavis/Fun-with-Masks/blob/master/Fun%20with%20Masks/EWDBlurExampleVC.m> 

Mind you, this is slower than the other options on this page.

```
#import <QuartzCore/QuartzCore.h>

- (UIImage*) blur:(UIImage*)theImage
{   
    // ***********If you need re-orienting (e.g. trying to blur a photo taken from the device camera front facing camera in portrait mode)
    // theImage = [self reOrientIfNeeded:theImage];

    // create our blurred image
    CIContext *context = [CIContext contextWithOptions:nil];
    CIImage *inputImage = [CIImage imageWithCGImage:theImage.CGImage];

    // setting up Gaussian Blur (we could use one of many filters offered by Core Image)
    CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur"];
    [filter setValue:inputImage forKey:kCIInputImageKey];
    [filter setValue:[NSNumber numberWithFloat:15.0f] forKey:@"inputRadius"];
    CIImage *result = [filter valueForKey:kCIOutputImageKey];

    // CIGaussianBlur has a tendency to shrink the image a little, 
    // this ensures it matches up exactly to the bounds of our original image
    CGImageRef cgImage = [context createCGImage:result fromRect:[inputImage extent]];

    UIImage *returnImage = [UIImage imageWithCGImage:cgImage];//create a UIImage for this function to "return" so that ARC can manage the memory of the blur... ARC can't manage CGImageRefs so we need to release it before this function "returns" and ends.
    CGImageRelease(cgImage);//release CGImageRef because ARC doesn't manage this on its own.

    return returnImage;

    // *************** if you need scaling
    // return [[self class] scaleIfNeeded:cgImage];
}

+(UIImage*) scaleIfNeeded:(CGImageRef)cgimg {
    bool isRetina = [[[UIDevice currentDevice] systemVersion] intValue] >= 4 && [[UIScreen mainScreen] scale] == 2.0;
    if (isRetina) {
        return [UIImage imageWithCGImage:cgimg scale:2.0 orientation:UIImageOrientationUp];
    } else {
        return [UIImage imageWithCGImage:cgimg];
    }
}

- (UIImage*) reOrientIfNeeded:(UIImage*)theImage{

    if (theImage.imageOrientation != UIImageOrientationUp) {

        CGAffineTransform reOrient = CGAffineTransformIdentity;
        switch (theImage.imageOrientation) {
            case UIImageOrientationDown:
            case UIImageOrientationDownMirrored:
                reOrient = CGAffineTransformTranslate(reOrient, theImage.size.width, theImage.size.height);
                reOrient = CGAffineTransformRotate(reOrient, M_PI);
                break;
            case UIImageOrientationLeft:
            case UIImageOrientationLeftMirrored:
                reOrient = CGAffineTransformTranslate(reOrient, theImage.size.width, 0);
                reOrient = CGAffineTransformRotate(reOrient, M_PI_2);
                break;
            case UIImageOrientationRight:
            case UIImageOrientationRightMirrored:
                reOrient = CGAffineTransformTranslate(reOrient, 0, theImage.size.height);
                reOrient = CGAffineTransformRotate(reOrient, -M_PI_2);
                break;
            case UIImageOrientationUp:
            case UIImageOrientationUpMirrored:
                break;
        }

        switch (theImage.imageOrientation) {
            case UIImageOrientationUpMirrored:
            case UIImageOrientationDownMirrored:
                reOrient = CGAffineTransformTranslate(reOrient, theImage.size.width, 0);
                reOrient = CGAffineTransformScale(reOrient, -1, 1);
                break;
            case UIImageOrientationLeftMirrored:
            case UIImageOrientationRightMirrored:
                reOrient = CGAffineTransformTranslate(reOrient, theImage.size.height, 0);
                reOrient = CGAffineTransformScale(reOrient, -1, 1);
                break;
            case UIImageOrientationUp:
            case UIImageOrientationDown:
            case UIImageOrientationLeft:
            case UIImageOrientationRight:
                break;
        }

        CGContextRef myContext = CGBitmapContextCreate(NULL, theImage.size.width, theImage.size.height, CGImageGetBitsPerComponent(theImage.CGImage), 0, CGImageGetColorSpace(theImage.CGImage), CGImageGetBitmapInfo(theImage.CGImage));

        CGContextConcatCTM(myContext, reOrient);

        switch (theImage.imageOrientation) {
            case UIImageOrientationLeft:
            case UIImageOrientationLeftMirrored:
            case UIImageOrientationRight:
            case UIImageOrientationRightMirrored:
                CGContextDrawImage(myContext, CGRectMake(0,0,theImage.size.height,theImage.size.width), theImage.CGImage);
                break;

            default:
                CGContextDrawImage(myContext, CGRectMake(0,0,theImage.size.width,theImage.size.height), theImage.CGImage);
                break;
        }

        CGImageRef CGImg = CGBitmapContextCreateImage(myContext);
        theImage = [UIImage imageWithCGImage:CGImg];

        CGImageRelease(CGImg);
        CGContextRelease(myContext);
    }

    return theImage;
}

```

Stack blur (Box + Gaussian)
---------------------------

* [StackBlur](https://github.com/tomsoft1/StackBluriOS) This implements a mix of Box and Gaussian blur. 7x faster than non accelerated gaussian, but not so ugly as box blur. See a demo in [here](http://incubator.quasimondo.com/processing/fast_blur_deluxe.php) (Java plugin version) or [here](http://www.quasimondo.com/StackBlurForCanvas/StackBlurDemo.html) (JavaScript version). This algorithm is used in KDE and Camera+ and others. It doesn't use the Accelerate Framework but it's fast.

Accelerate Framework
--------------------

* In the session “Implementing Engaging UI on iOS” from [WWDC 2013](https://developer.apple.com/wwdc/videos/) Apple explains how to create a blurred background (at 14:30), and mentions a method [`applyLightEffect`](https://developer.apple.com/downloads/download.action?path=wwdc_2013/wwdc_2013_sample_code/ios_uiimageeffects.zip) implemented in the sample code using Accelerate.framework.
* [GPUImage](https://github.com/BradLarson/GPUImage) uses OpenGL shaders to create dynamic blurs. It has several types of blur: GPUImageBoxBlurFilter, GPUImageFastBlurFilter, GaussianSelectiveBlur, GPUImageGaussianBlurFilter. There is even a GPUImageiOSBlurFilter that “should fully replicate the blur effect provided by iOS 7's control panel” ([tweet](https://twitter.com/bradlarson/status/391684261369368576/), [article](http://www.sunsetlakesoftware.com/2013/10/21/optimizing-gaussian-blurs-mobile-gpu)). The article is detailed and informative.

```

    -(UIImage *)blurryGPUImage:(UIImage *)image withBlurLevel:(NSInteger)blur {
        GPUImageFastBlurFilter *blurFilter = [GPUImageFastBlurFilter new];
        blurFilter.blurSize = blur;
        UIImage *result = [blurFilter imageByFilteringImage:image];
        return result;
    }

```

* From indieambitions.com: [Perform a blur using vImage](http://indieambitions.com/idevblogaday/perform-blur-vimage-accelerate-framework-tutorial/). The algorithm is also used in [iOS-RealTimeBlur](https://github.com/alexdrone/ios-realtimeblur).
* From Nick Lockwood: <https://github.com/nicklockwood/FXBlurView> The example shows the blur over a scroll view. It blurs with dispatch\_async, then syncs to call updates with UITrackingRunLoopMode so the blur is not lagged when UIKit gives more priority to the scroll of the UIScrollView. This is explained in Nick's book [iOS Core Animation](http://www.informit.com/store/ios-core-animation-advanced-techniques-9780133440751), which btw it's great.
* [iOS-blur](https://github.com/JagCesar/iOS-blur) This takes the blurring layer of the UIToolbar and puts it elsewhere. Apple will reject your app if you use this method. See <https://github.com/mochidev/MDBlurView/issues/4>
* From Evadne blog: [LiveFrost: Fast, Synchronous UIView Snapshot Convolving](http://blog.radi.ws/post/61836396624/livefrost-fast-synchronous-uiview-snapshot-convolving). Great code and a great read. Some ideas from this post: 

	+ Use a serial queue to throttle updates from CADisplayLink.
	+ Reuse bitmap contexts unless bounds change.
	+ Draw smaller images using -[CALayer renderInContext:] with a 0.5f scale factor.

Other stuff
-----------

Andy Matuschak [said](http://twitter.com/andy_matuschak/status/345677479534542848) on Twitter: “you know, a lot of the places where it looks like we're doing it in real time, it's static with clever tricks.” 

At [doubleencore.com](http://www.doubleencore.com/2013/09/the-essential-ios-7-design-guide/) they say “we’ve found that a 10 pt blur radius plus a 10 pt increase in saturation best mimics iOS 7’s blur effect under most circumstances”. 

A peek at the private headers of Apple's [SBFProceduralWallpaperView](https://github.com/JaviSoto/iOS7-Runtime-Headers/blob/master/PrivateFrameworks/SpringBoardFoundation.framework/SBFProceduralWallpaperView.h).

Finally, this isn't a real blur, but remember you can set rasterizationScale to get a pixelated image: <http://www.dimzzy.com/blog/2010/11/blur-effect-for-uiview/>
I think the easiest solution to this is to override UIToolbar, which blurs everything behind it in iOS 7. It's quite sneaky, but it's very simple for you to implement, and fast!

You can do it with any view, just make it a subclass of `UIToolbar` instead of `UIView`. You can even do it with a `UIViewController`'s `view` property, for example...

1) create a new class that is a "Subclass of" `UIViewController` and check the box for "With XIB for user interface".

2) Select the View and go to the identity inspector in the right-hand panel (alt-command-3). Change the "Class" to `UIToolbar`. Now go to the attributes inspector (alt-command-4) and change the "Background" color to "Clear Color".

3) Add a subview to the main view and hook it up to an IBOutlet in your interface. Call it `backgroundColorView`. It will look something like this, as a private category in the implementation (`.m`) file.

```
@interface BlurExampleViewController ()
@property (weak, nonatomic) IBOutlet UIView *backgroundColorView;
@end

```

4) Go to the view controller implementation (`.m`) file and change the `-viewDidLoad` method, to look as follows:

```
- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.barStyle = UIBarStyleBlack; // this will give a black blur as in the original post
    self.backgroundColorView.opaque = NO;
    self.backgroundColorView.alpha = 0.5;
    self.backgroundColorView.backgroundColor = [UIColor colorWithWhite:0.3 alpha:1];
}

```

This will give you a dark gray view, which blurs everything behind it. No funny business, no slow core image blurring, using everything that is at your fingertips provided by the OS/SDK.

You can add this view controller's view to another view, as follows:

```
[self addChildViewController:self.blurViewController];
[self.view addSubview:self.blurViewController.view];
[self.blurViewController didMoveToParentViewController:self];

// animate the self.blurViewController into view

```

Let me know if anything is unclear, I'll be happy to help!

---

Edit
----

UIToolbar has been changed in 7.0.3 to give possibly-undesirable effect when using a coloured blur.

We used to be able to set the colour using `barTintColor`, but if you were doing this before, you will need to set the alpha component to less than 1. Otherwise your UIToolbar will be completely opaque colour - with no blur.

This can be achieved as follows: (bearing in mind `self` is a subclass of `UIToolbar`)

```
UIColor *color = [UIColor blueColor]; // for example
self.barTintColor = [color colorWithAlphaComponent:0.5];

```

This will give a blue-ish tint to the blurred view.