/UIView-Blur

Dynamic blur for UIView using UIVisualEffectView

Primary LanguageSwift

UIView-Blur

Dynamic blur for UIView using UIVisualEffectView

  1. Put a transparent UIView over the elements that you need to blur (button, text field, etc.)
  2. Then initialize blur view:
import UIKit

class ViewController: UIViewController {
    
    @IBOutlet weak var viewForBlur: UIView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.viewForBlur.isUserInteractionEnabled = false;
        _ = self.viewForBlur.blurView.setup(style: .light, intensity: 0);
    }
    
}
  1. At any time you can change the blur intensity:
@IBAction func valueChanged(_ sender: Any) {
    self.viewForBlur.blurView.intensity = CGFloat((sender as! UISlider).value);
}

Video Preview (Youtube) IMAGE ALT TEXT HERE