I am setting a background image to view controller. But also i want to add blur effect to this background. How can I do this?
I am setting background with following
For Swift 3 (iOS 10.0 and 8.0)
var darkBlur:UIBlurEffect = UIBlurEffect()
if #available(iOS 10.0, *) { //iOS 10.0 and above
darkBlur = UIBlurEffect(style: UIBlurEffectStyle.prominent)//prominent,regular,extraLight, light, dark
} else { //iOS 8.0 and above
darkBlur = UIBlurEffect(style: UIBlurEffectStyle.dark) //extraLight, light, dark
}
let blurView = UIVisualEffectView(effect: darkBlur)
blurView.frame = self.view.frame //your view that have any objects
blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
view.addSubview(blurView)