Weird shadow behind popover view in iOS 13.1 and 13.2 only
Asked Answered
M

1

8

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

Malpractice answered 18/10, 2019 at 9:24 Comment(1)
Any way to remove this background color Priyanka M V ?Polarize
A
4

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
            }
        }
    }
}
Ararat answered 21/2, 2020 at 6:43 Comment(2)
This does solve the problem, can be used till new solution is available.Polarize
would you tell us where to apple the UIImageView under UIContextMenu ?Sly

© 2022 - 2024 — McMap. All rights reserved.