1

I have seen many libraries and examples on how to blur everything found behind a UIView. I would like to do something similar.

In my UIView I am drawing a custom shape using UIBezierPaths and everything else is transparent - I would like to fill this bezier path with a blurred version of what is underneath it.

So, how can I blur what is found beneath a UIBezierPath without blurring an entire UIView?

xizor
  • 1,554
  • 2
  • 16
  • 35

1 Answers1

1

Make a blurred image, to act as the "underneath it" stand-in. Put it in a UIImageView.

Now use the bezier path to draw an image, and fill the bezier path black (leaving the image transparent clear outside the bezier path). Attach this image as a mask to the UIImageView's layer. You have just clipped the UIImageView to the shape of the bezier path, giving the desired effect.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • And see my answer here: http://stackoverflow.com/a/16475824/341994 I'm clipping a view to be round, whereas you are going to clip the view to be the shape of some more exotic bezier path, but the principle is exact the same and you will even be able to reuse most of my code. – matt Apr 05 '14 at 21:31
  • 1
    This answer could really do with an example ;) – brandonscript Sep 26 '14 at 18:03