I don't want my background image to be too blury. Isn't there a property to adjust the blur intensity?
let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light) blurEffect.??? let effectView = UIVisualEffectView(effect: blurEffect) effectView.frame = backgroundAlbumCover.bounds backgroundAlbumCover.addSubview(effectView)
You can do that in super elegant way with animator
(reducing UIVisualEffectView alpha will not affect blur intensity, so we must use animator)
Usage as simple as:
let blurEffectView = BlurEffectView() view.addSubview(blurEffectView)
BlurEffectView realisation:
class BlurEffectView: UIVisualEffectView { var animator = UIViewPropertyAnimator(duration: 1, curve: .linear) override func didMoveToSuperview() { guard let superview = superview else { return } backgroundColor = .clear frame = superview.bounds //Or setup constraints instead setupBlur() } private func setupBlur() { animator.stopAnimation(true) effect = nil animator.addAnimations { [weak self] in self?.effect = UIBlurEffect(style: .dark) } animator.fractionComplete = 0.1 //This is your blur intensity in range 0 - 1 } deinit { animator.stopAnimation(true) } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With