[英]How to make UIButton always on top, and change able to change the subviews?
[英]How to force a UIButton to always be on top
我有一个UIButton
和一个UIView
动画,按下UIButton
时向下滑动。 问题是UIView
掩盖了UIButton
。 我希望UIButton
始终保持领先UIButton
。
我在viewDidLoad
试过这个:
[self.view bringSubviewToFront:categoryBtn];
虽然不起作用。
谢谢你的帮助
在此主视图上添加任何UIView
或任何其他视图后,只需添加此行以作为按钮的超级视图
[self.view bringSubviewToFront:categoryBtn];
有关按钮操作事件的示例,您可以添加任何视图,然后使用类似下面的代码。
-(IBAction)yourButton_Clicked:(id)sender
{
///Add some code or view here and then after write this line here see bellow line
[self.view bringSubviewToFront:categoryBtn];
}
另一个答案是可行的,但这正是添加“insertSubview:belowSubview”的事情。
[self.view insertSubview:myNewView belowSubview:_categoryBtn];
这允许您在视图堆栈上的按钮下添加新视图,而不是将其添加到按钮上方,然后重新排列视图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.