簡體   English   中英

僅在 iOS 13.1 和 13.2 中彈出視圖后面的奇怪陰影

[英]Weird shadow behind popover view in iOS 13.1 and 13.2 only

即使彈出背景顏色很明顯,彈出視圖后面有一個奇怪的陰影,此問題僅在 13.1 和 13.2 中發生,並且在 13 及以下版本中運行良好

我可以在視圖層次結構中看到 UIWindow/UITransitionView/_UICutoutShadowView 具有僅在 13.1 中具有陰影圖像的圖像視圖,但圖像視圖在 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)

奇怪的影子圖片

在 UI 檢查中有一個 _UICutoutShadowView 類型的 UIImageView 導致它。 所以我設法通過創建一個自定義 UIPopoverBackgroundView 並隱藏這個幽靈視圖來解決這個問題。

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
            }
        }
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM