gpt4 book ai didi

ios - 当 View Controller 被关闭时,补充 View 会短暂保留

转载 作者:行者123 更新时间:2023-11-28 06:34:57 25 4
gpt4 key购买 nike

我在 Collection View 的顶部添加了一个 View ,现在当我关闭 View 时,该 View 会保留一瞬间。有谁知道可能导致这种情况的原因吗?

let newView = UIView() newView.backgroundColor = UIColor.redColor() 

newView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(newView)

let pinTop = NSLayoutConstraint(item: newView, attribute: .Top, relatedBy: .Equal, toItem:

self.topLayoutGuide, attribute: .Bottom, multiplier: 1.0, constant: 0)

let heightConstraint = newView.heightAnchor.constraintEqualToAnchor(nil, constant: 50)

let widthConstraint = NSLayoutConstraint(item: newView, attribute: .Width, relatedBy: .Equal, toItem: view, attribute: .Width, multiplier: 1.0, constant: 0)

self.topContentAdditionalInset = 50

NSLayoutConstraint.activateConstraints([pinTop, heightConstraint, widthConstraint])

enter image description here

enter image description here

enter image description here

最佳答案

如果您使用 viewController 关闭它,请尝试在 viewWillDissapear 中添加 newView .removeFromSuperview() 并在 viewWillAppear 中重新添加它

关于ios - 当 View Controller 被关闭时,补充 View 会短暂保留,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39323270/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com