UIStackView Peek 和 Pop 覆盖故障

UIStackView Peek and Pop overlay glitch

我正在尝试使用 UIStackView 的内容实现 Peek 和 Pop。问题在于浅按期间的叠加层(未模糊的部分)不包含正确的内容。它在正确的位置,因为它就在我的手指下方,但内容似乎是从视图的其他地方获取的:

重现步骤:

  1. 使用故事板打开一个空的 iOS 项目
  2. 添加一个UIStackView到视图控制器的视图
  3. 从堆栈视图的所有四个边添加最近的邻居约束等于 0
  4. 用下面的代码替换ViewController.swift的内容:

    import UIKit
    
    class ViewController: UIViewController {
        @IBOutlet var stackView: UIStackView!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            registerForPreviewing(with: self, sourceView: stackView)
    
            let loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus sed feugiat ligula. Sed in rutrum lacus, vel auctor felis. Vivamus molestie felis nisi. Mauris euismod eros vitae libero commodo porttitor. Nam posuere, dui vitae aliquam mollis, quam mauris tempus turpis."
    
            let label = UILabel()
            label.numberOfLines = 0
            label.text = repeatElement(loremIpsum, count: 4).joined(separator: "\n\n")
            stackView.addArrangedSubview(label)
        }
    }
    
    extension ViewController: UIViewControllerPreviewingDelegate {
        func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? {
            previewingContext.sourceRect = CGRect(x: location.x - 50, y: location.y - 50, width: 100, height: 100)
            return storyboard?.instantiateInitialViewController()
        }
    
        func previewingContext(_ previewingContext: UIViewControllerPreviewing, commit viewControllerToCommit: UIViewController) {
            present(viewControllerToCommit, animated: true)
        }
    }
    
  5. 运行 您(物理)设备上的应用程序并强制触摸任何地方

我是不是做错了什么,或者这是 UIKit 中的错误?

编辑:这是我预期的行为方式:

正在替换

registerForPreviewing(with: self, sourceView: stackView)

来自

registerForPreviewing(with: self, sourceView: view)

解决了问题。我仍然怀疑这是一个错误,但至少这是一个解决方法。