sendSubviewToBack
和 insertSubview: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/