gpt4 book ai didi

ios - 如何在 uiview 上分配更高级别以使其覆盖另一个 View ?

转载 作者:行者123 更新时间:2023-11-28 12:48:52 26 4
gpt4 key购买 nike

我创建了一个 uiview 并在其上添加了一个子 uiview。然后我允许用户在屏幕上自由拖动 subview 。但是在屏幕顶部移动 subview 时遇到问题。请看下图。 subview 覆盖屏幕上的顶部 uiview。我想要的是让顶层的uiview覆盖子view。在这种情况下,如何更改 uiview 的级别?

enter image description here

当我使用 self.titleView.bringSubviewToFront(sv)

我看到另一个问题,如下图所示。状态栏不在 ImageView 的顶部。

enter image description here

最佳答案

您可以在父 View 上使用 bringSubviewToFront 将 subview 置于最前面,如下所示:

objective-C :

[parentView bringSubviewToFront:childView];

swift :

parentView.bringSubviewToFront(childView)

编辑:

使用以下方法管理 View :

bringSubviewToFront(_:)
sendSubviewToBack(_:)
removeFromSuperview()
insertSubview(_:atIndex:)
insertSubview(_:aboveSubview:)
insertSubview(_:belowSubview:)
exchangeSubviewAtIndex(_:withSubviewAtIndex:)

喜欢,

self.view.sendSubviewToBack(myView)

更多细节检查:https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/#//apple_ref/doc/uid/TP40006816-CH3-SW46

希望这有帮助:)

关于ios - 如何在 uiview 上分配更高级别以使其覆盖另一个 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37138978/

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