Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

How to control the blur radius of an UIImageView

Hi, I am working on my todolist app. In a page, I am using an image that is slightly blurred. In Sketch, I can control the blur radius of that image, but I am not sure how to do that in Swift. I have already tried the UIBlurEffect, but I cannot control the amount of blur.

let lightBlur = UIBlurEffect(style: UIBlurEffectStyle.Light)
let blurView = UIVisualEffectView(effect: lightBlur)
blurView.frame = imageForHeader.bounds
imageForHeader.addSubview(blurView)

Can someone tell me how to do that?

1 Answer

Hey, UIBlurEffect doesn't have a property for the blur radius, instead check out this:

http://code.tutsplus.com/tutorials/adding-blur-effects-on-ios--cms-21488

Here you can find how to make a better blur effect where you could specify the blur radius