GameDev
GameDev

Reputation: 515

Blur background no longer working in iOS14

Currently working on someone else's existing project for a client, however having this weird issue on iOS14 devices only where every screen that had a blurred background is not appearing blurred anymore but just like a transparent grey overlay image with a low alpha value. Ive tried various things and looked online but still cant find the issue here.

  override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    animatedCircleView.alpha = 1

    imvLogo.isHidden = false
    
    // Hero
    imvLogo.hero.id = "logo"
    imvLogo.hero.modifiers = [.duration(self.animatedDuration)]
    
    let blurEffect = (NSClassFromString("_UICustomBlurEffect") as! UIBlurEffect.Type).init()
    blurEffect.setValue(8, forKeyPath: "blurRadius")
    blurView = UIVisualEffectView(effect: blurEffect)
    blurView.frame = UIScreen.main.bounds
    blurView.alpha = 1
    view.insertSubview(blurView, aboveSubview: imvBackground)
  }

Here is what the blurred background look like before on iOS13:

enter image description here

enter image description here

and here is what it now looks like on iOS14:

enter image description here

enter image description here

I also tried changing the code to this, but it just gives me a solid background color instead of a blurred background:

let blurEffect = UIBlurEffect(style: .light)
blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = UIScreen.main.bounds
blurEffectView.alpha = 0
view.insertSubview(blurEffectView, aboveSubview: viewUnder)

Here is the solid background color its giving me instead:

enter image description here

If anyone could tell me what might be wrong or whats broken this in iOS14 that would be great and how i could go about fixing this. Thanks.

UPDATE:

I checked the view hierarchy and on ios13 the UIVisualEffectBackdropView is created correctly (see image):

enter image description here

But the ios14 UIVisualEffectBackdropView is created incorrectly and is just taking the background image and applying a tint to it but no blur:

enter image description here

Upvotes: 1

Views: 1361

Answers (1)

user2115512
user2115512

Reputation: 21

@GameDev

Actually, this code uses the private API _UICustomBlurEffect that no longer works since iOS 14. You have to fall back on a regular UIBlurEffect subclass but you won't be able to set the blurRadius...

Upvotes: 2

Related Questions