xpams / UIView-Blur

Dynamic blur for UIView using UIVisualEffectView

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

Dynamic blur for UIView using UIVisualEffectView


Languages

Language:Swift 100.0%