0
我正在試圖用UIStackView
的內容實現Peek和Pop。問題在於淺印刷過程中的覆蓋層(未模糊的部分)不包含正確的內容。這是在正確的地方,因爲它是正確的下面我的手指,但內容似乎是從視圖帶往別處:UIStackView Peek和Pop覆蓋小故障
重現步驟:
- 打開一個空的iOS項目中使用故事板
- 一個
UIStackView
添加到視圖控制器的看法 - 從等於堆棧視圖四邊添加的近鄰約束
0
替換的內容
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) } }
你的(物理)設備和力觸摸運行應用程序的任何地方
我做得不對,或者這是UIKit中的錯誤嗎?