gpt4 book ai didi

ios - 从顶部收缩 UIView

转载 作者:行者123 更新时间:2023-11-28 14:31:11 29 4
gpt4 key购买 nike

我有一个 uiview,它在 superview 之上覆盖并阻止与我的 View 的交互。我试过将被阻挡的 View 放在前面,但这也不起作用。

这是阻塞 View 的代码:

self.gesstureView = UIView(frame: screenBounds)
if let gestureView = self.gesstureView, let controlDockView = self.controlDockView, let controlTopView = self.controlTopView {
gestureView.autoresizingMask = [.flexibleWidth, .flexibleBottomMargin]
gestureView.frame.size.height -= controlDockView.frame.height
gestureView.contentMode = .center
gestureView.backgroundColor = UIColor.red
self.view.addSubview(gestureView)

这是被阻止的 View 的代码:

let topHeight = screenBounds.height * 0.15
self.controlTopView = UIView(frame: CGRect(x: 0, y: 0, width: screenBounds.width, height: topHeight))
if let controlTopView = self.controlTopView {
controlTopView.backgroundColor = UIColor.clear
controlTopView.autoresizingMask = [.flexibleTopMargin]
controlTopView.addBlurEffect()
self.view.addSubview(controlTopView)
// does not work view is still hidden
self.view.bringSubview(toFront: controlTopView)

enter image description here

最佳答案

感谢您提供示例代码!

问题是在将 controlTopView 置于最前面之后,您将 gestureView 添加到 View 层次结构中。所以 controlTopView 实际上是第二个 View ,这就是它不可见的原因。 Problem

要解决此问题,请在最后添加 controlTopView 或在添加所有内容后将其置于最前面。

view.addSubview(previewView)
view.addSubview(controlDockView)
view.addSubview(gestureView)
view.addSubview(controlTopView)

Solution

关于ios - 从顶部收缩 UIView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51253362/

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