0

I know we can use UIBlurEffect to show user a blurred image with the following code, but how to only get a blurred image (layer is better)?

 let baseView = UIView(frame: CGRect(x: 0, y: 0, width: gScreenWidth, height: 90))

 let backgroundImageView = UIImageView(frame: CGRect(x: 0, y: 0, width: gScreenWidth, height: 90))
 let blurEffect = UIBlurEffect(style:  .light)
 let blurView = UIVisualEffectView(effect: blurEffect)
 blurView.frame = backgroundImageView.frame

 baseView.addSubview(backgroundImageView)
 baseView.addSubview(blurView)
JsW
  • 1,682
  • 3
  • 22
  • 34
  • move this line blurView.frame = backgroundImageView.frame to the `viewDidLayoutSubViews` method – Reinier Melian Dec 03 '17 at 07:56
  • @ReinierMelian Thank you. I just mentioned it as a `UIBlurEffect` example. – JsW Dec 03 '17 at 08:25
  • 1
    If a `UIBlurEffect` isn't working well enough for you, use CoreImage. https://developer.apple.com/library/content/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/uid/TP30000136-SW29 –  Dec 03 '17 at 10:52
  • I don't know what yo uare exactly asking, but whenever you need something more, use CoreImage. – Dominik Bucher Dec 04 '17 at 01:18
  • possible duplicate https://stackoverflow.com/questions/41156542/how-to-blur-an-existing-image-in-a-uiimageview-with-swift/41157042#41157042 – Joe Dec 04 '17 at 14:07

0 Answers0