Search code examples
iosswiftxcode11

Xcode 11 and iOS 13 Modal ViewController lost black overlay


I have a UIViewController A which presents modally another UIViewController B which takes up only the bottom half the screen height.

Back when I was still using Xcode 10, when the modal ViewController B is presented, a dark overlay will cover ViewController A and I will also set the view.alpha of ViewController A to 0.5 using these methods:

func presentBottomSheet() {

  let viewController = BottomSheetModalVC()
  viewController.modalPresentationStyle = .overCurrentContext

  DispatchQueue.main.async { [weak self] in
        self?.dimParent()
        self?.parentViewController?.present(viewController, animated: true, completion: nil)
  }
}

func dimParent() {
 UIView.transition(with: parentVC.view, duration: 0.6, options: [.curveEaseOut], animations: {
   parentVC.view.alpha = 0.5
 })
}

in order to shift the user's focus to the modal view. However, when I tried to compile this with Xcode 11, the black overlay is done and I am left with a parent view who only becomes half visible when the modal view slides up from the bottom. Was there a change in this overlay behaviour?

My screen looks something similar to this. But after Xcode 11, the black overlay is no longer there leaving me with a completely transparent overlay. enter image description here


Solution

  • Found my own answer to this silly question.

    So it turns out that the UINavigationController presenting ViewController A & B had its background color set to white so when ViewController A has its alpha set to 0.5, it just looks like it was disappearing but not dimming.

    I have set my NavigationController background color to black now and everything is back to normal.