ML-Works / Bluuur

MIT License
3 stars 4 forks source link

Bluuur not working on iOS 14 #1

Open Mallenow opened 3 years ago

Mallenow commented 3 years ago

Hello,

first of all i want to thank you for the nice framework. But unfortunately it doesn't work properly on iOS 14. After I updated my device, the blur effect does not displayed anymore. The area is only displayed in grayscale.

Here are my functions:

    func blurThemAll(){
        let blurView = MLWBluuurView()
        let navBlur = MLWBluuurView()
        self.navigationController?.navigationBar.addSubviewWithoutAnimation(subview: navBlur)
        blurView.colorTintAlpha = 0
        blurView.colorTint = .BLACK_141B2C
        view.addSubviewWithoutAnimation(subview: blurView)

        UIView.animate(withDuration: 0.4) {
            navBlur.blurRadius = 8
            blurView.colorTintAlpha = 0.6
            blurView.blurRadius = 8
        }
    }

    func allBlurMustDie(){
        var blurView : MLWBluuurView?
        var navBlur : MLWBluuurView?

        self.view.subviews.forEach { view in
            if view.isKind(of: MLWBluuurView.self){
                blurView = view as? MLWBluuurView
            }
        }

        navigationController?.navigationBar.subviews.forEach({ view in
            if view.isKind(of: MLWBluuurView.self){
                navBlur = view as? MLWBluuurView
            }
        })

        UIView.animate(withDuration: 0.4, animations: {
            navBlur?.blurRadius = 0
            blurView?.colorTintAlpha = 0
            blurView?.blurRadius = 0
        }) { _ in
            blurView?.removeFromSuperview()
            navBlur?.removeFromSuperview()
        }
    }

I hope you can help me with this issue quickly.

Many thanks Mallenow

podkovyrin commented 3 years ago

Bluuur is built on top of the private class _UICustomBlurEffect which seems no longer works in iOS 14.

Mallenow commented 3 years ago

Will the framework be updated in the near future?

danh-geo commented 3 years ago

@Mallenow I would give this a try: https://github.com/unboxme/Blurberry so far so good.

podkovyrin commented 3 years ago

@danh-geo @Mallenow

https://github.com/unboxme/Blurberry

While this seems quite comprehensive I wouldn't use it in production because of the extensive use of private APIs (For the same reason, I wouldn't use Bluuur today). Recently I found out quite an elegant way to set the blur radius using vanilla UIKit:

    private let animator: UIViewPropertyAnimator

    override init(frame: CGRect) {
        let visualEffectView = UIVisualEffectView(effect: nil) // must be nil

        animator = UIViewPropertyAnimator(duration: 1, curve: .linear, animations: {
            visualEffectView.effect = UIBlurEffect(style: .regular)
        })

...

    // set the needed radius with a percentage:
    animator.fractionComplete = 0.5