Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Weird shadow behind popover view in iOS 13.1 and 13.2 only

Even though pop over background colour is clear there is a weird shadow behind the popover view this issue is happening only in 13.1 and 13.2 and it is working fine in 13 and below

I can see in view hierarchy that UIWindow/UITransitionView/_UICutoutShadowView has image view with shadow image which is only in 13.1 but image view has empty image in 13

controller.modalPresentationStyle = .popover
controller.popoverPresentationController?.permittedArrowDirections = .up
controller.popoverPresentationController?.delegate = controller
controller.popoverPresentationController?.sourceView = sourceView
controller.popoverPresentationController?.popoverBackgroundViewClass = FilterBackgroundView.self
present(controller, animated: false)

strange shadow image

like image 529
Priyanka M V Avatar asked Oct 18 '19 09:10

Priyanka M V


1 Answers

On UI inspect there is a UIImageView of type _UICutoutShadowView which is causing it. So I managed to fix this by creating a custom UIPopoverBackgroundView and hiding this ghost view.

override func didMoveToWindow() {
    super.didMoveToWindow()
    if #available(iOS 13, *) {
        // iOS 13 (or newer)
        if let window = UIApplication.shared.keyWindow {
            let transitionViews = window.subviews.filter { String(describing: type(of: $0)) == "UITransitionView" }
            for transitionView in transitionViews {
                let shadowView = transitionView.subviews.filter { String(describing: type(of: $0)) == "_UICutoutShadowView" }.first
                shadowView?.isHidden = true
            }
        }
    }
}
like image 65
Dinesh Jeyasankar Avatar answered Nov 15 '22 13:11

Dinesh Jeyasankar