¿Cómo implementa Path el desenfoque dinámico detrás de la barra de búsqueda?

Experimenté un poco y descubrí una forma en que podría funcionar. Básicamente, tenemos dos vistas de imagen una encima de la otra, una detrás con la original y otra en frente con la misma imagen borrosa. Luego usamos un CALayer como una máscara en la imagen borrosa donde está la barra de búsqueda. Cuando el usuario se desplaza, habilitando el desplazamiento de paralaje en ese encabezado, nuestras dos imágenes se desplazan juntas mientras la máscara CALayer se compensa para permanecer en el mismo lugar en la pantalla.

Aquí hay un código de muestra que escribí que mostrará una máscara animando en la pantalla, dando la apariencia de que hay un cuadro en movimiento creando desenfoque debajo de ella. Sé que no es el más bonito, pero espero que se entienda)

// imagen borrosa original
UIImage * image = [UIImage imageNamed: @ “sample_profile_bg.jpg”];

CIImage * inputImage = [[CIImage alloc] initWithImage: image];

CIFilter * filter = [CIFilter filterWithName: @ “CIGaussianBlur”];

[filter setValue: inputImage forKey: kCIInputImageKey];

[filter setValue: [NSNumber numberWithFloat: 5.0f] forKey: @ “inputRadius”];

CIImage * result = [filter valueForKey: kCIOutputImageKey];

UIImageView * newView2 = [[UIImageView alloc] initWithFrame: self.view.bounds];
newView2.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
newView2.image = [UIImage imageWithCIImage: result];
[self.view addSubview: newView2];
[self.view sendSubviewToBack: newView2];

// enmascarando la imagen borrosa
CALayer * currentLayer = [capa CALayer];
currentLayer.frame = CGRectMake (0.0f, 0.0f, 1000.0f, 120.0f);
currentLayer.backgroundColor = [UIColor blackColor] .CGColor;
newView2.layer.mask = currentLayer;

// muestra de animación para mostrar la naturaleza dinámica del desenfoque
CGPoint endPoint = CGPointMake (0, currentLayer.position.y + 280.0f);
CGPoint currentPoint = [posición currentLayer];

CABasicAnimation * anim = [CABasicAnimation animationWithKeyPath: @ “position”];
[anim setFromValue: [NSValue valueWithCGPoint: currentPoint]];
[anim setToValue: [NSValue valueWithCGPoint: endPoint]];
[anim setDelegate: self];
[anim setDuration: 5.0];

[anim setValue: @ “stackLayer” forKey: @ “kind”];
[anim setValue: [NSNumber numberWithInt: 0] forKey: @ “index”];

[currentLayer setPosition: endPoint];
[currentLayer addAnimation: anim forKey: @ “position”];

// agregando la imagen no borrosa detrás de la imagen borrosa
UIImageView * newView = [[UIImageView alloc] initWithFrame: self.view.bounds];
newView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
newView.image = imagen;
[self.view addSubview: newView];
[self.view sendSubviewToBack: newView];

(¿hay una mejor manera de mostrar el código en quora?)