gpt4 book ai didi

iphone - sendSubviewToBack 和 insertSubview :belowSubview: don't work as they should 的问题

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

sendSubviewToBackinsertSubview:belowSubview: 方法有问题。简单地说,我有一个按钮,我将其插入到另一个 View _centerView 下方。我希望按钮保持在 _centerView 下方。

我面临的问题是,当我在 _centerView 下方插入一个按钮时,我看到 _centerView 上出现闪烁(只是短暂的一瞬间)。我尝试了 sendSubviewToBack:insertSubview:belowSubview: - 相同的效果。

您知道哪些地方可能出了问题吗?我错过了什么吗?这是我的代码:

    UIButton* itemButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[itemButton setFrame:CGRectMake(0, 0, 40, 40)];
[itemButton setCenter:_centerView.center];

[parentView bringSubviewToFront:_centerView];
[parentView insertSubview:itemButton belowSubview:_centerView];

最佳答案

我最近遇到了同样的问题,但将此选项传递给动画代码修复了它。希望这对你也有帮助。如果没有您的评论,我不会想出我的解决方案,所以谢谢您:)

UIViewAnimationOptionShowHideTransitionViews

关于iphone - sendSubviewToBack 和 insertSubview :belowSubview: don't work as they should 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11037478/

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